Hi, In my application I have 6 arrays which represents 6 jobs that my application performs.Each job is basically interacting with database and filling each element of array.
What I did is create 6 threads and make the 6 arrays global so that the threads can fill them.I have also created a array of 6 bool elements(ThreadsAlive).When a thread finishes it's execution, it sets a flag in the bool array.I created a job watcher thread(threadwatcher) to monitor this bool thread.When all the elements in that array are set to false, i will be sure that my jobs are completed.
Now, the problem is that, due to some bug in Oledb driver, the ExecuteReader() statement stucks in some thread and never recover and my application continues forever.Actually the bug can be "resolved" can restarting that particular job.Next time that job may run successfully.
What my plan is that I will make all the 6 threads as Fields and along with the ThreadsAlive array, i will also maintain a LastActivityOfThreads array of DateTime.
All the job threads will update the time in that array when they execute a query.Now my jobwatcher thread will monitor if the Last activity time of any thread is more than, say 3 min ago.If that happens, it will kill that thread and restart it.
Just wanted to know how can I kill any thread without raising an exception.
Update:I did that and it's showing exception that "Thread was being aborted"
Update:Maybe I use seperate process(exe) for each operation and in the main application constantly monitor the processes.If a process will take longer than usual, I will just kill the process and restart it.
But in this case how will the 6 processes running will give me the data of 6 arrays ?
Update:Is it possible that while pooling, if i find any thread suspended, i will use
th = new Thread(Fun_Name) and let the old thread where it was.