new System.Threading.Thread(() =>
{
var myObject = new CustomObject();
myObject.SomeEvent += SomeMethod;
}).Start();
Part 1: Assume I run the above code on my main UI thread in a winforms applications. Which Thread will calls to SomeMethod occur on? Will they occur on the same Thread that was created when I created the object?
Part 2: Using Visual Studio 2010, how can I figure this out on my own? I don’t know where you find out what Thread something is running on.
The event handler
SomeMethodwill run on whatever thread raised the event.You can set a breakpoint in the event handler
SomeMethodand look at the Threads window (you will probably want to give your threads meaningful names to find them).