Access of common thread by WCF service and windows service in c#.net 3.0
-
Hello, I am developing a windows service using the WCF technology(this contains the windows service and also hosts a webservice) in C#.net3.0. I am developing this on the windows XP platform. Here, i have two class files WCFservice.cs and WindowsService.cs. There is a single thread declared, started (in OnStart()) and Aborted(OnStop()) methods of the WindowsService.cs file. Now, my requirement is to, suspend() and resume() the same thread in the WCFservice.cs file. since, the WCFservice class is inherited from IWCFservice and WindowsService class is inherited from the ServiceBase class, i am unable to fix my problem of accessing the same threadObj from both these files. Can anyone help me here... Thank you Anee.. Anee
-
Hello, I am developing a windows service using the WCF technology(this contains the windows service and also hosts a webservice) in C#.net3.0. I am developing this on the windows XP platform. Here, i have two class files WCFservice.cs and WindowsService.cs. There is a single thread declared, started (in OnStart()) and Aborted(OnStop()) methods of the WindowsService.cs file. Now, my requirement is to, suspend() and resume() the same thread in the WCFservice.cs file. since, the WCFservice class is inherited from IWCFservice and WindowsService class is inherited from the ServiceBase class, i am unable to fix my problem of accessing the same threadObj from both these files. Can anyone help me here... Thank you Anee.. Anee
I think, you could, in the OnStart function that runs first, store a reference to the current running thread: Thread _currentThread; OnStart() { _currentThread = Thread.CurrentThread; } This should give you a handle to the current thread. You could then add the following code which can be invoked from a different thread: void Suspend() { _currentThread.Suspend() //Depracated - Use Alternative Threading Technique } void Resume() { _currentThread.Resume() //Depracated - Use Alternative Threading Technique } This isn't a good solution, but it's a rought template that might nudge you in the right direction. Alternatively, it may not be what you're looking for. :) Hope it helps anyway. Tris
------------------------------- Carrier Bags - 21st Century Tumbleweed.