![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
br> br> |
| |||||||
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| Guest | ServiceHost in a Form Hi there, I've successfully implemented a client and a server running from the static Main method of a Windows Forms application. For example: [STAThread] static void Main() { MyServer server = new MyServer(); MyClient client = new MyClient("http://localhost/myServer"); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); } The MyClient contructors contains a method call to the server, and receives a response from the server. Everything works great. BUT, if I wish to perform the same server-client code sample within the Form1 instance (e.g. after a button click etc'), I get a 'timed out' exception. My guess is that it is probably a threading issue, and that the Form's mainthread is blocking the ServiceHost of the server. If this is correct, then I must say that I thought I read somewhere that the ServiceHost is always running on a different thread. So, any ideas as to what the problem is and how to solve it? |
| | #3 (permalink) |
| Guest | Re: ServiceHost in a Form Yes , that exactly , the problem , service need to listen for client(s) request, but your client sit on the same thread. BTW why you need client and service in the same app , that against tenet 1 of web services. If you have service/client pair talk to different service/client pair that's OK , but not in this case Arkady "ewolfman" <ewolfman@yahoo.com> wrote in message news:1151299765.256777.310920@m73g2000cwd.googlegroups.com... > Eventually I ended up in performing the hosting and client connection > on different threads, and it worked-around the problem. > > However, I'll be happy if someone posts a solution to this. > > Thanks. > |
| | #6 (permalink) |
| Guest | Re: ServiceHost in a Form No, I meant that you have client and service on the same thread. You have to separate client and service , those have to be two different applications Arkady "ewolfman" <ewolfman@yahoo.com> wrote in message news:1151314200.399066.198430@u72g2000cwu.googlegroups.com... > They don't have to exist in the same app - it occurs between different > apps too. I just wanted to demonstrate the problem. > > According to your answer, a WinForm application can only host outside > the main thread - did I understand correctly? > |
| | #7 (permalink) |
| Guest | Re: ServiceHost in a Form I see now , in this case form and host service run on the same thread Arkady "ewolfman" <ewolfman@yahoo.com> wrote in message news:1151331282.931319.305360@i40g2000cwc.googlegroups.com... > As I mentioned, the blocking occurs on 2 different applications (i.e. > client and server running in different applications). > |
| | #8 (permalink) |
| Guest | Re: ServiceHost in a Form As I initially mentioned, this is what I gather the problem to be. Do we have a method of hosting on a different thread? I thought I read somewhere that it is automatically handled, but I guess it isn't so. So my question is, what is the correct way of hosting in a WinForms application ? |
| | #9 (permalink) |
| Guest | Re: ServiceHost in a Form Just as you did : create the thread and host service there, btw if you mean service behavior concurrencymode( multiple ) that not work with many clients but only one after another ( when previous client close connection ) even in Beta 2 ![]() Arkady "ewolfman" <ewolfman@yahoo.com> wrote in message news:1151404338.477824.15860@p79g2000cwp.googlegroups.com... > As I initially mentioned, this is what I gather the problem to be. Do > we have a method of hosting on a different thread? I thought I read > somewhere that it is automatically handled, but I guess it isn't so. > > So my question is, what is the correct way of hosting in a WinForms > application ? > |
| |
| |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| form problems | PowerShell | 5 | 09-26-2007 01:24 PM | |