473,395 Members | 1,938 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

how do i abort a process of any thread that is taking time more than 8 seconds.

18
hi all,

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
  1. public partial class MainForm : Form  
  2.    {   
  3.       int count = 0;  
  4.        string scrpt_path, scrpt_file;
  5.        DateTime strt_time, end_time;     
  6.     TimeSpan duration;    
  7.  
  8.  Thread t1 = new Thread(new parameterizedThreadStart(RunProcess));
  9.  Thread t2 = new Thread(new ParameterizedThreadStart(RunProcess));
  10.  
  11.  System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer();
  12.  
  13.    private void timer1_Tick(object sender, EventArgs e)
  14.         {
  15.             if (!t1.IsAlive)
  16.             {
  17.                 t1 = new Thread(new ParameterizedThreadStart(RunProcess));
  18.                 t1.Start("C:\\New folder\\abc.vbs");
  19.  
  20.             }
  21.            if (!t2.IsAlive)
  22.             {
  23.                 t2 = new Thread(new ParameterizedThreadStart(RunProcess));
  24.                 t2.Start("C:\\New folder\\Dummy.vbs");
  25.             }
  26.  
  27.         }
  28.  
  29.         static void RunProcess(object file)
  30.         {
  31.  
  32.            string VbFile = (string)file;
  33.             Process p = new Process();
  34.             p.StartInfo.FileName = VbFile;
  35.             p.Start();
  36.  
  37.         }
  38.  
  39.     }
  40.  
Nov 5 '08 #1
0 1167

Sign in to post your reply or Sign up for a free account.

Similar topics

77
by: Charles Law | last post by:
Hi guys I have a time critical process, running on a worker thread. By "time critical", I mean that certain parts of the process must be completed in a specific time frame. The time when the...
2
by: cottonviking | last post by:
Greetings, all! I've been pondering the pitfalls of aborting a secondary thread in a service app I'm writing (VB, fx v1.1). Everything I've read so far pretty much dissuades one from aborting one...
20
by: Doug Thews | last post by:
I ran into an interesting re-pain delay after calling the Abort() method on a thread, but it only happens the very first time I call it. Every time afterward, there is no delay. I've got a...
13
by: Andy Fish | last post by:
Hi, I am using COM interop to invoke MS word from my .net app. If word pops up a dialog box, my thread obviously hangs until the dialog is answered. Here's the problem: because the app is...
5
by: [Yosi] | last post by:
Why I can't abot a susspended thread. Who can terminat a thread imediatly without consider to its stat or execution?
4
by: Mufasa | last post by:
Is there any way to force a thread to abort and really have it abort? I have a thread that every once in a while gets hung to so I kill it. Problem is I have a thread that every once in a while...
6
by: mehdi | last post by:
Hi folks, You know, the Thread class has got a method named Abort which according to the msdn: "Raises a ThreadAbortException in the thread on which it is invoked, to begin the process of...
1
by: masaniparesh | last post by:
Hi, In my C# program i am termination thread by thread.Abort when times out occur. But i figured out that even after thread.Abort operation the thread is being alive for the random time. I have...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.