G
greg.merideth
I have a class that I've provided an event for to be called when the
processing in the class is complete (a callback). The class spins up a
series of threads for the background operation and I'm firing the
callback delgate from within one of the new threads. So far, all is
well but I'm curious as to what, threading wise, is going on there.
I'm instantiating the class in the app thread (say 1) and providing a
method to call when processing is done. My class is in thread 1 yet
I'm starting up threads 2 and 3. Thread 3 fires the callback delegate
when it's done processing so is that considered an unsafe thread
operation? Does .net shift the call back to thread 1 being the
delegate is part of the class declaration or is the call in my app
(thread 1) being called by thread 3 get 'moved' into thread 3's pool
meaning it would be unsafe to perform operations on data from within
the callback method?
Would it be more effective to switch the calls to async delegates and
let .net handle the threading and callback?
processing in the class is complete (a callback). The class spins up a
series of threads for the background operation and I'm firing the
callback delgate from within one of the new threads. So far, all is
well but I'm curious as to what, threading wise, is going on there.
I'm instantiating the class in the app thread (say 1) and providing a
method to call when processing is done. My class is in thread 1 yet
I'm starting up threads 2 and 3. Thread 3 fires the callback delegate
when it's done processing so is that considered an unsafe thread
operation? Does .net shift the call back to thread 1 being the
delegate is part of the class declaration or is the call in my app
(thread 1) being called by thread 3 get 'moved' into thread 3's pool
meaning it would be unsafe to perform operations on data from within
the callback method?
Would it be more effective to switch the calls to async delegates and
let .net handle the threading and callback?