Click here to Skip to main content
15,891,726 members
Home / Discussions / C#
   

C#

 
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 
AnswerRe: Await - Async not so simple to use? Pin
Nathan Minier24-Jan-17 14:22
professionalNathan Minier24-Jan-17 14:22 
Well, it looks like you're firing of the thread.sleep on the UI (calling) thread so...that's expected.

A better test case might look like:
C#
private async void button1_Click(object sender, EventArgs e)
        {
            listBox.Items.AddRange(new object[] {"Hello", "There", "Code", "Project."});
            var task = Task.Run(() => PerformLengthyTask()).ContinueWith(s => DoSomethingWithBool(s));
        }

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

This will push the method onto a different thread, will not block, and will take a callback.

Really async and await are ways to transition from an asynchronus context into a synchronous one. The await keyword ostensibly forces code execution into a synchronous context by marking a place where a Task.Result needs to be available.

Async and await make life much, much easier in terms of interacting with async code, but they are not a silver bullet on their own.

For detailed reading have a look at:
Task-based Asynchronous Pattern (TAP)
"There are three kinds of lies: lies, damned lies and statistics."
- Benjamin Disraeli

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 
GeneralRe: Await - Async not so simple to use? Pin
Richard Deeming25-Jan-17 10:23
mveRichard Deeming25-Jan-17 10:23 
GeneralRe: Await - Async not so simple to use? Pin
Jon McKee25-Jan-17 10:49
professionalJon McKee25-Jan-17 10:49 
AnswerRe: Await - Async not so simple to use? Pin
Graeme_Grant25-Jan-17 1:31
mvaGraeme_Grant25-Jan-17 1:31 
AnswerRe: Await - Async not so simple to use? Pin
Richard Deeming25-Jan-17 3:12
mveRichard Deeming25-Jan-17 3:12 
GeneralRe: Await - Async not so simple to use? Pin
Richard Andrew x6425-Jan-17 10:08
professionalRichard Andrew x6425-Jan-17 10:08 
QuestionDelegates Pin
Member 1202181724-Jan-17 2:13
Member 1202181724-Jan-17 2:13 
AnswerRe: Delegates Pin
Richard Deeming24-Jan-17 2:20
mveRichard Deeming24-Jan-17 2:20 
AnswerRe: Delegates Pin
OriginalGriff24-Jan-17 2:26
mveOriginalGriff24-Jan-17 2:26 
QuestionPlz Send Me The Simpler Answer to connect with SSIS And SSRS Both In any Version fo the Excell Pin
Member 889223723-Jan-17 23:45
Member 889223723-Jan-17 23:45 
GeneralRe: Plz Send Me The Simpler Answer to connect with SSIS And SSRS Both In any Version fo the Excell Pin
Richard MacCutchan24-Jan-17 0:42
mveRichard MacCutchan24-Jan-17 0:42 
Questionnumber converter Pin
ab_ayo23-Jan-17 1:51
ab_ayo23-Jan-17 1:51 
AnswerRe: number converter Pin
Richard MacCutchan23-Jan-17 2:07
mveRichard MacCutchan23-Jan-17 2:07 

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.