user557351
user557351

Reputation: 11

Multithreading using Wcf

HI i am new to the the whole programming thing, i have been given a task to multithread 4 stored procedures where each thread runs asynchronously so that the user can get output real quick i have to do it using WCF can anyone help me out with this. Initially what i am trying to do is taking each procedure and getting how much time it takes to execute using parametrizedthreadstart, but i am not sure how to go about it.

Upvotes: 1

Views: 1310

Answers (2)

Gaurav
Gaurav

Reputation: 21

Considering you are new to the whole programming thing, you can follow these very basic steps to get thing done.

  1. Create a new WCF service.
  2. Add 4 methods each calling one stored procedure.
  3. Add parameters to the methods which are required by stored procedures. For Example if your stored procedure is - MySP(varchar name) then your WCF method will be - MySP(string name);
  4. Now depoly your service in IIS or windows service or Console App or wherever you want.
  5. Create a client application, again it could be anything ConsoleApp or Win Form etc.
  6. Add a reference to your service.
  7. Instantiate service class and call there Async version. By Async I mean there you'll see all of the four methods with Async attached. For Example you will find your MySP(string name) method as MySPAsync(string name)
  8. Also there will be MySPCompleted event, subscribe to it.
  9. Now all of your methods are running asynchronously whenever they finish execution they'll call your subscribed methods.

I hope this helps you get started :)

Upvotes: 2

Josh
Josh

Reputation: 10624

There are a couple of different ways to do this. At the highest level, you can place each service request in it's own service endpoint. This could be defining endpoints for each method, or if you are hosting in IIS, placing each service it's own website. At the lower level, you could define callbacks for each method so that WCF will not block while the method calls are taking place.

Upvotes: 0

Related Questions