![]() |
Executing a remote program from a thread within a service
I have a C# client/server program that functions as expected. In attempts to get rid of the console window being displayed, I tried nesting the server code into a service with threads and such.
The problem occurs when the client tries to send across an "execute transaction", which executes a client specified program on the server. The remote process terminates but somehow doesn't let my program know, so the process hangs until I kill it. I'm exectuing the remote program by using the Process method: :
Process myProcess;No matter how many milliseconds I use, the thread never receives the notice of termination of the remote process so the client hangs. Is there any way I can kill the process after a specified interval and notify the thread that it died? I am also open to eliminating the console window another way, outside of services and threads... if anyone has any suggestions. |
Quote:
Try this: ... using System.Runtime.InteropServices; ... -------------------------------- And at the top of your class, put this: :
[DllImport("user32.dll")]-------------------------------- And within the Main function put this: :
IntPtr hWnd = FindWindow(null, System.Windows.Forms.Application.ExecutablePath ); //put your console window caption here-------------------------------- If you wanted it to show again, you could do this: :
if(hWnd != IntPtr.Zero) |
Thank you so much IR!!! This is exactly what I needed.
|
| All times are GMT -5. The time now is 2:04 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC