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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T22:14:54+00:00 2026-05-14T22:14:54+00:00

I am attempting to push updates into a process via a named pipe, but

  • 0

I am attempting to push updates into a process via a named pipe, but in doing so my process loop now seams to stall on while ((line = sr.ReadLine()) != null). I’m a little mystified as to what might be wrong as this is my first foray into named pipes.

void RefreshThread()
{
    using (NamedPipeServerStream pipeStream = new NamedPipeServerStream("processPipe", PipeDirection.In))
    {
        pipeStream.WaitForConnection();

        using (StreamReader sr = new StreamReader(pipeStream))
        {
            for (; ; )
            {
                if (StopThread == true)
                {
                    StopThread = false;
                    return;                 // exit loop and terminate the thread
                }

                // push update for heartbeat
                int HeartbeatHandle = ItemDictionary["Info.Heartbeat"];
                int HeartbeatValue = (int)Config.Items[HeartbeatHandle].Value;
                Config.Items[HeartbeatHandle].Value = ++HeartbeatValue;
                SetItemValue(HeartbeatHandle, HeartbeatValue, (short)0xC0, DateTime.Now);

                string line = null;
                while ((line = sr.ReadLine()) != null)
                {
                    // line is in the format: item, value, timestamp
                    string[] parts = line.Split(',');

                    // push update and store value in item cache
                    int handle = ItemDictionary[parts[0]];
                    object value = parts[1];
                    Config.Items[handle].Value = int.Parse(value);
                    DateTime timestamp = DateTime.FromBinary(long.Parse(parts[2]));
                    SetItemValue(handle, value, (short)0xC0, timestamp);
                }

                Thread.Sleep(500);
            }
        }
    }
}

The solution to this problem was to make the RefreshThread() monitor a Queue<string> for data, and a separate thread to handle the pipe and push the strings received through the pipe into the Queue<string>

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

    This is by design, PipeStream.Read() is a blocking call. You could use BeginRead() instead. This makes text less than a stellar format for data of course. Not a real problem, use PipeTransmissionMode.Message.

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

Sidebar

Related Questions

I am currently attempting to push html updates to a page for a user
I'm (attempting) to use push notifications with Android via Urban Airship. I've register for
Attempting to implement a poor man's test of whether a process is still running
Attempting to use XStream's JavaBeanConverter and running into an issue. Most likely I'm missng
I'm using the jQuery library, and attempting to push items to an array: <
I'm attempting to run the mvn release:prepare goal and it's hanging after the push.
Im attempting to write a push server for the iPhone in C#. I have
I'm attempting to push notifications to my iPhone, which I've successfully done using PHP.
I'm getting the following error when attempting to push/pull from my git repository which
Am attempting to add push notifications to an application that I have created. I

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.