0

The code in form1

private async Task btnStartDownload_Click(object sender, EventArgs e)
        {
            var mustStop = false;

            var downloadProgress = (long? _, long __, double? progressPercentage) =>
            {
                if (progressPercentage.HasValue)
                    progressBar.Value = (int)progressPercentage.Value;

                // In this example only the variable is checked
                // You could write other code that evaluates other conditions
                return mustStop;
            };

            for (int i = 0; i < list.Count; i++)
            {
                await Download(list[i], @"d:\testfiles\" + i.ToString() + ".png", downloadProgress);
            }
        }

I added to the button click event the async Task after creating the click event from the designer.

then after changing it to async Task I'm getting the error in the designer of form1:

this.btnStartDownload.Click += new System.EventHandler(this.btnStartDownload_Click);

the error is on the right side: this.btnStartDownload_Click

'Task Form1.btnStartDownload_Click(object, EventArgs)' has the wrong return type    

0 Answers0