Hello,
I am trying to get a thread working in C# to reset the time and run another function alongside it. The code I have is:
Thread loopTime = new Thread(this.someFunction);
loopTime.Start();
for (int i = 0; i < 20; i++)
{
ChangeTimeFunction(someTime);
Thread.Sleep(200);
}
I am getting a threading error if I pass in this.SomeFunction()
. This cannot be used according to Visual Studio. I could have the for loop as a thread but I do not know how to pass in the variable someTime
.
Is there a way to either pass the variable into the loop if it was a function or call the for loop from within the function.
Thanks for any help.
UPDATE:
someFunction is a recorded methods using Visual Studio. This cannot be used outside the main thread. I would need to put the for loop inside the thread I am creating. Does any one know how to do this?
Thanks