P
Peter Larsen [CPH]
Hi,
I am testing some WCF behavior when running threads and i have a question
related to this.
The following code:
private void StartThread()
{
Console.WriteLine("Thread (StartThread): " +
Thread.CurrentThread.ManagedThreadId.ToString());
Uri tcpAddr = new Uri("net.tcp://localhost:4322/ServerTcpService");
Uri httpAddr = new Uri("http://localhost:12346/MyService2");
host = new ServiceHost(typeof(ContractClass), new Uri[] { tcpAddr,
httpAddr });
host.Open();
Console.WriteLine("Service host is open");
}
The code starts a WCF listener and if i run this from the mainthread, all
requests (from clients) are received in the same thread (the main thread).
Running the WFC in its own thread, each client is receievd in different
threads.
E.g. the mainthread runs in ID 10, the worker thread is running in thread ID
11.
Running two clients, the requests are received in thread ID 11 and 13.
Is this working by design ?
Running the WFC host in its own thread, makes the code more responsive, but
i'm not sure whether its ok to start the WCF listener in its own thread or
not. Is it ??
Best Regards
Peter
I am testing some WCF behavior when running threads and i have a question
related to this.
The following code:
private void StartThread()
{
Console.WriteLine("Thread (StartThread): " +
Thread.CurrentThread.ManagedThreadId.ToString());
Uri tcpAddr = new Uri("net.tcp://localhost:4322/ServerTcpService");
Uri httpAddr = new Uri("http://localhost:12346/MyService2");
host = new ServiceHost(typeof(ContractClass), new Uri[] { tcpAddr,
httpAddr });
host.Open();
Console.WriteLine("Service host is open");
}
The code starts a WCF listener and if i run this from the mainthread, all
requests (from clients) are received in the same thread (the main thread).
Running the WFC in its own thread, each client is receievd in different
threads.
E.g. the mainthread runs in ID 10, the worker thread is running in thread ID
11.
Running two clients, the requests are received in thread ID 11 and 13.
Is this working by design ?
Running the WFC host in its own thread, makes the code more responsive, but
i'm not sure whether its ok to start the WCF listener in its own thread or
not. Is it ??
Best Regards
Peter