Showing posts with the label Threading

Notify Async operation in C#

Threading is a nice thing until we know how it is being executed. Sometime it can be a pain in the arse and sometimes asset you gain from. Today came across a question on how to get to know a async operation is completed thought of spending some time to explain it in my way.
How do you get to know a Async operation is completed, well one way is IAsyncResult,this is how we go,
Lets create a delegate that will be used call our time consuming or background task.
delegatestringCallFunctionDelegate(string arg1, string arg2);say the time consuming function

privatestring DoSomeThingBig(string arg1, string arg2)
just to show how to pass argument, i have used some dummy arguments.

Once the time consuming function is completed lets call the notification function that will called after the asynchronous operation let that be

privatevoid AfterDoingSomethingBig(IAsyncResult result)

Now for this kind of function signature we have a delegate class called AsyncCallback
next will create an instance for that d…