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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:44:28+00:00 2026-06-14T22:44:28+00:00

I have a problem that I’m hoping is easily solved. I’ve scoured for an

  • 0

I have a problem that I’m hoping is easily solved. I’ve scoured for an answer for the past few days, but no luck yet. What I’m trying to do is have a static dictionary represent connected clients, end goal being to send all of the connected clients data such as other player locations. Anyway, what I’ve done so far is when the client first connects, I add them to the static dictionary like so:

RegionServer.RegionClients.Add(UserId, this);
Log.DebugFormat("Added peer to region list");

foreach (var client in RegionServer.RegionClients)
{
     Log.DebugFormat("Client id in list : {0}", client.Key);
}

I added in the debug statements to make sure that the client is really being added to the list, of which it is.

Then in my main file I have:

public override  void InitBackgroundThreads()
    {
        ThreadPool.QueueUserWorkItem(SendUpdatesToAll);
    }

public void SendUpdatesToAll(object threadContext)
    {
        Stopwatch timer = new Stopwatch();
        timer.Start();
        isRunning = true;

        while (isRunning)
        {
            if (timer.Elapsed < TimeSpan.FromMilliseconds(100))
                continue;

            Update(timer.Elapsed);
            timer.Restart();
        }
    }

public void Update(TimeSpan elapsed)
    {

        foreach (KeyValuePair<Guid, Unity3dPeer> peer in RegionClients)
                {
                    Log.DebugFormat("Inside the foreach statement");
                }

In my debug log I can see that the loop is indeed looping, but the RegionClients dictionary values are never updated. The foreach loop is never iterated as there doesn’t seem to be a client in the dictionary. Any help will be greatly appreciated, this problem has been driving me crazy! Thanks in advance.

-Jarryd

  • 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-14T22:44:29+00:00Added an answer on June 14, 2026 at 10:44 pm

    It turns out it was something simple. I have a cluster server going and I was trying to reference this dictionary from different processes…duh. Thanks for the ideas, it turns out was simpler than trying to be thread safe.

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

Sidebar

Related Questions

I have a problem that I thought was easily solved, but is turning out
(I have a problem that I illustrated in this question but had no correct
i have a problem that i can't solve ! (sqlite3, but i think it
this is my regex for digital dnumbers: \d+(.\d+)+(,\d+) but now i have problem that
I have the problem that my Faces ActionEvent returns a source, but the check
Have a problem that seems easy on paper but i'm having a big problem
I have problem that I need to create timer but I want to pass
I have problem that seems to be rather trivial but I was not able
I have problem that i cant find a solution for with regular expressions, but
I close form with form.Dispose() but i have problem that all opened MessageBoxes does

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.