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 5935253
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T15:13:41+00:00 2026-05-22T15:13:41+00:00

I am trying to write a WCF Servce which will reside in a Windows

  • 0

I am trying to write a WCF Servce which will reside in a Windows Service. This WCF Service will just add strings to a list and then the worker thread will process this list periodically. What is the best way to achieve this? I have read conflicting examples which has left me confused. What is the best way of the service and thread sharing a list object?

Update:
Thanks for the replies so far. Just to clarify, I am not struggling with the synchronization of the list or how to make it thread safe. That all seems the same principles as what I am used to in C++. What I am struggling with is where to define this list so it is accessible from both the WCF service and the worker thread. In C++ I would have created the list at global scope but C# doesn’t have a global scope. If I define it in the WCF service class, the thread can’t see it. If I definite it in the service class (where the thread function is defined and started) the WCF service cannot see it. I am sure I did something similar to this in ATL some time ago but it’s Friday afternoon and the grey cells have given up for the day.

Update2:
Where should I be defining the worker thread? In the Windows Service class (i.e. the host) or in the WCF Service? Should the WCF Service be a singleton service which has a list member and a thread function? That solves the access issue. Having done a lot of COM, I’m thinking of a WCF service as a COM component with the instance dying after it is accessed. This led me to want to put the static list and thread function in the Windows service class. That still feels the more natural place for it but perhaps I am just not thinking in a .NET way.

  • 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-05-22T15:13:42+00:00Added an answer on May 22, 2026 at 3:13 pm

    1) Create Windows Service

    2) Host WCF in the WS ( http://msdn.microsoft.com/en-us/library/ms731758.aspx )

    3) Make a thread synchronization ( http://www.albahari.com/threading/part2.aspx )

    4) profits!

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

Sidebar

Related Questions

No related questions found

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.