Click here to Skip to main content
15,914,409 members
Home / Discussions / C#
   

C#

 
AnswerRe: .net Reading and Saving Very Large Images Pin
OriginalGriff26-Jan-17 4:31
mveOriginalGriff26-Jan-17 4:31 
AnswerRe: .net Reading and Saving Very Large Images Pin
Eddy Vluggen26-Jan-17 4:49
professionalEddy Vluggen26-Jan-17 4:49 
QuestionNeed help creating a META file (*.meta) editor Pin
KrazyMonkey Modding25-Jan-17 18:45
KrazyMonkey Modding25-Jan-17 18:45 
SuggestionRe: Need help creating a META file (*.meta) editor Pin
Richard MacCutchan25-Jan-17 21:38
mveRichard MacCutchan25-Jan-17 21:38 
AnswerRe: Need help creating a META file (*.meta) editor Pin
NotPolitcallyCorrect26-Jan-17 1:12
NotPolitcallyCorrect26-Jan-17 1:12 
AnswerRe: Need help creating a META file (*.meta) editor Pin
Dave Kreskowiak26-Jan-17 2:46
mveDave Kreskowiak26-Jan-17 2:46 
AnswerRe: Need help creating a META file (*.meta) editor Pin
Gerry Schmitz26-Jan-17 7:29
mveGerry Schmitz26-Jan-17 7:29 
QuestionDataSet to SDF in C#? Pin
Simmerliner25-Jan-17 12:37
Simmerliner25-Jan-17 12:37 
GeneralRe: DataSet to SDF in C#? Pin
Richard MacCutchan25-Jan-17 21:37
mveRichard MacCutchan25-Jan-17 21:37 
QuestionGetting value into dropdown from db MVC Pin
eejaynic25-Jan-17 8:53
eejaynic25-Jan-17 8:53 
Questionweb control browser Pin
jigishaben25-Jan-17 2:37
jigishaben25-Jan-17 2:37 
AnswerRe: web control browser Pin
OriginalGriff25-Jan-17 2:56
mveOriginalGriff25-Jan-17 2:56 
QuestionMessage Closed Pin
25-Jan-17 1:18
professionalJackson Savitraz25-Jan-17 1:18 
AnswerRe: Fuzzy IndexOf using Bitap Algorithm Pin
OriginalGriff25-Jan-17 1:52
mveOriginalGriff25-Jan-17 1:52 
QuestionAppending data to existing excel file using C# Pin
Member 1296649424-Jan-17 15:34
Member 1296649424-Jan-17 15:34 
AnswerRe: Appending data to existing excel file using C# Pin
Ralf Meier24-Jan-17 22:18
mveRalf Meier24-Jan-17 22:18 
AnswerRe: Appending data to existing excel file using C# Pin
Richard MacCutchan24-Jan-17 22:34
mveRichard MacCutchan24-Jan-17 22:34 
AnswerRe: Appending data to existing excel file using C# Pin
Patrice T25-Jan-17 10:55
mvePatrice T25-Jan-17 10:55 
QuestionAwait - Async not so simple to use? Pin
Richard Andrew x6424-Jan-17 12:24
professionalRichard Andrew x6424-Jan-17 12:24 
I have a form Form1 on which is a listbox and a button.

Consider the following code, and read the problem I am having with it below:

private async void button1_Click(object sender, EventArgs e)
{
    listBox.Items.AddRange(new object[] {"Hello", "There", "Code", "Project."});
    await PerformLengthyTask();
}

private async Task<bool> PerformLengthyTask()
{
    Thread.Sleep(5000);
    return true;
}

What I THOUGHT would happen when I clicked the button:
The new items would appear instantly in the listbox because while the UI thread is waiting for the PerformLengthyTask function, it is free to pump messages and keep the UI responsive. Roll eyes | :rolleyes:

What ACTUALLY happens when I click the button:
The new items do not appear in the listbox until after PerformLengthyTask returns. Confused | :confused:
And also, the form itself is frozen.

What is it that I do not understand about async methods that is causing me this confusion?



The difficult we do right away...
...the impossible takes slightly longer.

AnswerRe: Await - Async not so simple to use? Pin
Nathan Minier24-Jan-17 14:22
professionalNathan Minier24-Jan-17 14:22 
GeneralRe: Await - Async not so simple to use? Pin
Richard Andrew x6425-Jan-17 1:41
professionalRichard Andrew x6425-Jan-17 1:41 
AnswerRe: Await - Async not so simple to use? Pin
Jon McKee24-Jan-17 17:53
professionalJon McKee24-Jan-17 17:53 
GeneralRe: Await - Async not so simple to use? Pin
Richard Andrew x6425-Jan-17 1:42
professionalRichard Andrew x6425-Jan-17 1:42 
SuggestionRe: Await - Async not so simple to use? Pin
Richard Deeming25-Jan-17 3:09
mveRichard Deeming25-Jan-17 3:09 
GeneralRe: Await - Async not so simple to use? Pin
Jon McKee25-Jan-17 9:34
professionalJon McKee25-Jan-17 9:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.