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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:47:24+00:00 2026-05-23T00:47:24+00:00

I have a problem on a hand held device that should be listening for

  • 0

I have a problem on a hand held device that should be listening for messages from my server application. When the device loses connection to the network my server is on, this background worker (implemented from OpenNetCF) stops responding. I’ve placed messages in the ProgressChanged and RunWorkerCompleted events to see when they are raised, and in the following code after the RecieveFrom in the while loop, and after the loop termination, as well as in all of the exceptions. I don’t see the messages from the exceptions, or after the while loop at all, and the messages stop after the connection is lost. All of the messages are shown by setting the text in a visible label, with the background colour of the label changing so that I can see if the loop is running. The loop seems to stop running, even after the connection is re-gained, and attempting to re-run the backgroundworker generates an “Already in use” exception. So, why would the worker stop responding while continuing to run?

  private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
  {
      BackgroundWorker wWorker = (BackgroundWorker)sender;
      byte[] wBytes = new Byte[4096];
      string wsReceive;
      EndPoint wRemoteEP = (EndPoint)new IPEndPoint(IPAddress.Any, 0);

      try
      {
          while (true)
          {
              if (wWorker.CancellationPending)
              {
                  break;
              }

              mSocket.ReceiveFrom(wBytes, ref wRemoteEP);
              if (wBytes.Length < 1)
              {
                  continue;
              }
              wsReceive = Encoding.ASCII.GetString(wBytes, 0, wBytes.Length);

              wWorker.ReportProgress(0, wsReceive);
          }
          mSocket.Close();
      }
      catch (ThreadAbortException)
      {
      }
      catch (ThreadStateException)
      {
      }
      catch (Exception E)
      {
          MessageBox.Show(E.Message, "Communication Error");
      }
  }
  • 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-23T00:47:25+00:00Added an answer on May 23, 2026 at 12:47 am

    Right from the docs on Socket.ReceiveFrom:

    If no data is available for reading, the ReceiveFrom method will block until data is available

    So when communication is lost, you’re unable to receive and your ReceiveFrom call blocks indefinitely. It’s going to stop reporting anything while it waits for data, but the thread is still alive and therefore the BackgroundWorker can’t be re-run.

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

Sidebar

Related Questions

Problem : I have a hand held device that scans those graphic color barcodes
I have an application working on hand held device with .NET compact framework, using
I have a problem in hand and that is to fetch a result set
I have problem in some JavaScript that I am writing where the Switch statement
I have problem creating new instance of excel 2007 using VBA (from Access 2002).
I have problem with fancybox. I want to write a function that will run
I have a problem at hand which can be reduced to something like this
I have a problem at hand which I'd think is fairly common amongst groups
I have an application that has a good look on screens, but has a
There is an interesting problem at hand. I have a role-playing MMOG running through

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.