Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8543277
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T12:15:50+00:00 2026-06-11T12:15:50+00:00

I have an IIS hosted WCF webservice. It has a method on it (let’s

  • 0

I have an IIS hosted WCF webservice.

It has a method on it (let’s call it “ConfirmOrder”). When this method is called, I want to
1. Do some quick stuff to the database, resulting in an OrderId
2. Start a new thread that will do some slow work (e.g. generate an email and send it)
3. Return the OrderId from 1. synchronously to the client.
4. Eventually, when it’s finished, the new thread created in 2. will have done all the rest of the processing and sent the email.

Questions:

(1) I did have code like:

// do printing and other tasks 
OrderConfirmedThreadHelper helper = new OrderConfirmedThreadHelper(userSession, result);
// some things first (like generating barcodes) in this thread 
Logger.Write(basket.SessionId, String.Format("Before ConfirmOrderSync"), LogCategoryEnum.Sales, System.Diagnostics.TraceEventType.Verbose);
helper.ConfirmOrderSync();
Logger.Write(basket.SessionId, String.Format("After ConfirmOrderSync"), LogCategoryEnum.Sales, System.Diagnostics.TraceEventType.Verbose);
// slower things (like rendering, sending email) in a separate thread
Thread helperThread = new Thread(new ThreadStart(helper.ConfirmOrderAsync));
helperThread.Start();
return result;

but it seemed to cause problems; at least, the service kept locking up. Is this a bad thing to do?

(2) I tried changing it to

// slower things (like rendering, sending email) in a separate thread            
ThreadPool.QueueUserWorkItem(new WaitCallback(helper.ConfirmOrderAsync));

but the ThreadPool thread seems to be being killed as soon as the main thread has finished, because it’s a Background thread.

Is there a better way of doing this – short of writing a whole new windows service to communicate with?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T12:15:51+00:00Added an answer on June 11, 2026 at 12:15 pm

    If the second thead finishes after the request thread (the one that comes from the browser) you’re in problems, since it’ll get reclaimed by the runtime and terminated.
    If you can afford to wait (if it’s only going to send an email i’ll be a couple of seconds) you can use ManualResetEvent to synchronize one thread to wait for the other to finish and clean up gracefully.

    If you can’t wait, well the best choice in this case for the mail process is one of the following

    1. A Windows Service.
    2. An .ashx you can call from your client code with a jquery ajax call passing the necessary data to send the mail.
    3. A batch job (a scheduled task, a sql server job, etc) that reads pending mails to be sent from the DB and sends them. It would run every X minutes, so you wouldn’t have to worry

    Hope that helps!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a WCF service hosted in IIS and want to gain access to
I have a WCF service hosted in IIS 7. It takes some minutes until
I have a WCF Service Using MSMQ hosted on IIS. I want to create
I have a WCF service (.NET 4) hosted in IIS. My service contract has
I have a WCF webservice that is hosted in IIS 7.5. Inside the Service
I have IIS-Hosted WCF application and services. I want to automate the process to
I have an IIS hosted WCF service with single-call behavior. I use Fluent NH
I want to ask a question about IIS hosted Wcf Services. Our projects has
I have a WCF service hosted on IIS and it accepts connection like this
I have an IIS hosted WCF service (configured as described in this blog post

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.