I read many solution over here and other places but never got it right. I kinda feel embarrassed just by asking this but here I'm...
My code:
private void btnStart_Click(object sender, EventArgs e)
{
MyClass SomeData = new MyClass()
Thread ProcessThread = new Thread(c => StartService(SomeData));
ProcessThread.Start();
}
private void StartService(MyClass someData)
{
try
{
//System.Exception throws in this Execute method
someData.Execute();
}
catch(Exception Ex)
{
Show(Ex);
//Informing me some exception occurred.
}
}
When an exception is thrown in Excute method (which, currently I'm throwing it deliberately to test), I CANNOT abort
or end
the thread and start ANOTHER to run SAME method. So, basically if I would like to END that thread and then RE-RUN it again. If you think re-running is risky, I will put up a question that waits a human confirmation whether to re-run or end it. Anyways, I cannot even END it and the thread stays doing nothing at Thread ProcessThread = new Thread(c => StartService(SomeData));
line.
Could you please help me?