i am using this code to initialize and assign it to a process, i am calling a thread on every 10 Seconds to fire vbscript file, this activity is performed on "timer1_Tick( )" event and give me required information. some times i face problem that the second thread associated with "Dummy.vbs" script file, do not reach at specified remote machine, and give error message after 45 seconds to 1 minute,
i want that to terminate its process and thread after waiting 8 seconds, if that remote system is not responding.
how could i terminate thread that has not commited his process with in 8 seconds by giving any proper message
so here is given a code that i am using, some body please inform me about it.
Expand|Select|Wrap|Line Numbers
- public partial class MainForm : Form
- {
- int count = 0;
- string scrpt_path, scrpt_file;
- DateTime strt_time, end_time;
- TimeSpan duration;
- Thread t1 = new Thread(new parameterizedThreadStart(RunProcess));
- Thread t2 = new Thread(new ParameterizedThreadStart(RunProcess));
- System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer();
- private void timer1_Tick(object sender, EventArgs e)
- {
- if (!t1.IsAlive)
- {
- t1 = new Thread(new ParameterizedThreadStart(RunProcess));
- t1.Start("C:\\New folder\\abc.vbs");
- }
- if (!t2.IsAlive)
- {
- t2 = new Thread(new ParameterizedThreadStart(RunProcess));
- t2.Start("C:\\New folder\\Dummy.vbs");
- }
- }
- static void RunProcess(object file)
- {
- string VbFile = (string)file;
- Process p = new Process();
- p.StartInfo.FileName = VbFile;
- p.Start();
- }
- }