I’ve got a method that gets called on an event, which presents me with two variables varA, varB (both strings). This method gets called with new information quite frequently, thus I have created a separate method that takes in the two parameters. I want to run this method in a thread, however have struck the issue that Thread.Start will not accept parameters.
I’ve tried a few supposed methods, but have so far had no luck.. I think my best bet is to create a separate class, and handle it there.. However I have a List which I am inserting data into, and hit a dead end when the separate class tried to access that list, since it was in a different class.
Can someone help me out here please?
The start method of thread accepts an object parameter.
If your method accepts multiple parameters, then you can very well pass an object of your class containing the parameters into it. You can then unbox it in your method.
http://msdn.microsoft.com/en-us/library/system.threading.thread.start.aspx
Update
In your case, try this,
and in your method