P
pbd22
Hi.
I have a C# program that fires an external VB6 program which writes to
a file and terminates.
It is ugly, but this is how I have to do it. I cannot change this part
of the program.
The problem I am encountering is that the former process created by
this EXE is not complete
(it runs for a few seconds) when the next one wants to start. A
classic multi-threading situation (i think).
The current code looks like this:
proc = new System.Diagnostics.Process();
proc.EnableRaisingEvents = false;
proc.StartInfo.FileName = path2exe;
proc.StartInfo.Arguments = videoname;
proc.Start();
(and, I eventually added... proc.Kill();
A friend in another forum suggested I use Mutexes as a way of
queuing up requests - attaching to and detaching from the process as
needed.
He also suggested a timer given the longer length that the process
takes to complete.
I have never worked with mutexes before and am wondering if somebody
out there
could show me how this is done (or, at least, tell me what I am doing
wrong and where
to go).
I would appreciate some feedback on my first attempt:
static void somemethod()
{
Mutex mutex = new Mutex(false, "domain.com");
try
{
mutex.WaitOne();
Timer tmr = new Timer(MpgWriter);
tmr.Dispose();
}
finally
{
mutex.ReleaseMutex();
}
}
static void MpgWriter(object data)
{
Console.WriteLine("c:/myprocess.exe command1,
command2");
}
Thanks again for your help.
I have a C# program that fires an external VB6 program which writes to
a file and terminates.
It is ugly, but this is how I have to do it. I cannot change this part
of the program.
The problem I am encountering is that the former process created by
this EXE is not complete
(it runs for a few seconds) when the next one wants to start. A
classic multi-threading situation (i think).
The current code looks like this:
proc = new System.Diagnostics.Process();
proc.EnableRaisingEvents = false;
proc.StartInfo.FileName = path2exe;
proc.StartInfo.Arguments = videoname;
proc.Start();
(and, I eventually added... proc.Kill();
A friend in another forum suggested I use Mutexes as a way of
queuing up requests - attaching to and detaching from the process as
needed.
He also suggested a timer given the longer length that the process
takes to complete.
I have never worked with mutexes before and am wondering if somebody
out there
could show me how this is done (or, at least, tell me what I am doing
wrong and where
to go).
I would appreciate some feedback on my first attempt:
static void somemethod()
{
Mutex mutex = new Mutex(false, "domain.com");
try
{
mutex.WaitOne();
Timer tmr = new Timer(MpgWriter);
tmr.Dispose();
}
finally
{
mutex.ReleaseMutex();
}
}
static void MpgWriter(object data)
{
Console.WriteLine("c:/myprocess.exe command1,
command2");
}
Thanks again for your help.