473,508 Members | 2,247 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Wcf Service Multithread

1 New Member
Hy,
I have a Wcf service tat receives files from clients.
The contract:
Expand|Select|Wrap|Line Numbers
  1. #region ServiceContract   
  2.     [ServiceContract]   
  3.     public interface IWcfService   
  4.     {   
  5.         [OperationContract(AsyncPattern = true)]   
  6.         IAsyncResult BeginSendFile(UploadFile file, AsyncCallback callback, object state);   
  7.         FileTransfered EndSendFile(IAsyncResult ar);   
  8.  
  9.     }  
  10. #endregion ServiceContract  
  11.  
"UploadFile" and "FileTransfered" are messages.

and the service

Expand|Select|Wrap|Line Numbers
  1. [ServiceBehavior(ConcurrencyMode=ConcurrencyMode.Multiple, InstanceContextMode=InstanceContextMode.PerCall)]   
  2.     public class WcfService : IWcfService  
  3.  
The service class implements the asynchronous pattern (the BeginSendFile, EndSendFile and the synchronous method, SendFileToServer, which is called in the Callback method).

Ex1: If on the client I generate the proxy class with asynchronous operations and call BeginSendFile for each file, the server acts asynchronously (it processes multiple files at a time).
Ex2: But if I generate the proxy without asynchronous operations, and call SendFile in a thread from ThreadPool (ThreadPool.QueueUserWorkItem(...)), one for each file, the server acts synchronously (it processes the files one at a time).

Why doesn't the server act async on the Ex2 scenario?

P.S. I followed this tutorial this tutorial. On "Client" section, it is the Ex2 scenario
Dec 8 '08 #1
1 6984
mldisibio
190 Recognized Expert New Member
I have used asynchronous patterns, but not within WCF - that is, I have not used WCF so I am unfamiliar with the contract syntax.

I am glad you did not post all your code, because that would be unecessary. That said, I don't think you posted enough to indicate the problem.

When you use ThreadPool.QueueUserWorkItem, you need to supply the callback. Looking at the tutorial, the callback itself uses a ManualResetEvent to limit itself to processing one item at a time.

So one idea to look at, without seeing any more of your code, is to follow the signaling path and see if the the callback you are giving to QueueUserWorkItem is waiting for a signal that the previous task has finished.

That means not so much that the server is no longer working asynchronously, but rather that your client is limiting the server to only process the next task after the first one has finished.

I think in example one, you are sending several requests asynchronously. Sending the request is not signaled, so they all go out and the server processes them.

In example two, my hunch (it may be incorrect) is that the next request is queued but not sent until the first task signals it is finished.
Dec 8 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
1598
by: Alice | last post by:
Hello I have four multithread windows applications(vb.net) interacting and running on the same machine(windows 2000 with .net framework 1.0). All of them start a new thread each time Filewatcher's...
0
1842
by: r_obert | last post by:
Hello, I'm trying to create a worker thread for my VC++ program, and was wondering whether I should be linking with the Multithread /MT or Multithread DLL /MD option? I'm not quite sure, in...
4
7069
by: zbcong | last post by:
Hello: I write a multithread c# socket server,it is a winform application,there is a richtextbox control and button,when the button is click,the server begin to listen the socket port,waiting for a...
2
26482
by: zhebincong | last post by:
Hello: I write a multithread c# socket server,it is a winform application,there is a richtextbox control and button,when the button is click,the server begin to listen the socket port,waiting...
2
1268
by: Joseph | last post by:
Hi, I have 2 web services (WS1 and WS2). The sessionstate of WS1 is InProc and the sessionState of WS2 is Off. WS1 is calling a web method on WS2 from 2 different threads (i.e. WS1 triggered...
0
1304
by: fred | last post by:
I need some help in trying to understand how to make myCollection (inherited from CollectionBase) multithread safe. Taking my implementation of the Add Sub and a readonly property Item. Public...
6
2813
by: jmartin | last post by:
Hi, I have made a multithread version of a program (load a file into database), and with two processors I get the double of time in the multithread than in the process (unithread) version. I...
2
5280
by: tikcireviva | last post by:
Hi Guys, I've done a mulithread queue implementation on stl<queue>, my developement environment is on VC6 as well as FC3. Let's talks about the win32 side. The suspected memory leak is find...
1
2848
by: mdhaman | last post by:
hi, I have a windows service written in VB.Net and framework 2.0. It is a multithread service and it is using threadpool to manage threads. Recently I have started getting...
0
7231
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7401
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7063
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5640
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5059
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4720
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3211
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1568
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
432
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.