Asynchronous Callbacks
-
Before you think this is just another "How do I...?" please read. I DO NOT need to know how to do async operations. Here's my scenario... I am performing Async callbacks on a Form to retrieve data on a seperate thread. I am using Delegates not Threads. First, I am not simply calling one Query and Oh, we're done. I kick off about 7 different delegates to load data from different sources. I am using "SyncLocks" or "lock" in C# with different Lock objects per data I am retrieving. One thing that is happening now is that users are CLOSING my form while data is still loading. Obviously, this causes numerous errors because the Callbacks do not have a UI thread to go back to. My question is, how can I cancel an Async operation or gracefully exit running one?
-
Before you think this is just another "How do I...?" please read. I DO NOT need to know how to do async operations. Here's my scenario... I am performing Async callbacks on a Form to retrieve data on a seperate thread. I am using Delegates not Threads. First, I am not simply calling one Query and Oh, we're done. I kick off about 7 different delegates to load data from different sources. I am using "SyncLocks" or "lock" in C# with different Lock objects per data I am retrieving. One thing that is happening now is that users are CLOSING my form while data is still loading. Obviously, this causes numerous errors because the Callbacks do not have a UI thread to go back to. My question is, how can I cancel an Async operation or gracefully exit running one?
Since executing a delegate asynchronously means that the target method executes on a thread from the CLR's thread pool, you will not have fine-grain control over the worker thread. If you need the ability to manipulate the worker thread you should explicitly create it. Josh