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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:10:06+00:00 2026-06-13T23:10:06+00:00

I am encountering an absolutely bizarre behaviour in a Silverlight application on which I

  • 0

I am encountering an absolutely bizarre behaviour in a Silverlight application on which I am working. Please see the following code:

var replaySubject = new ReplaySubject<string>(1);
    replaySubject.OnNext("This can never block... surely?");

var s = replaySubject.First();
Debug.WriteLine(s);

Basically, my app comes through this piece of code repeated and it always prints out the message… except for in one particular scenario in which the thread blocks on the First() line.

It’s always on the UI thread. If I set a break point on the line with First(), and drill into the replaySubject with the debugger, I can see the string in its queue.

Can anyone think of any scenario that would cause the First() call to block here?

BTW: It’s RX version 1.1.11111

  • 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-13T23:10:06+00:00Added an answer on June 13, 2026 at 11:10 pm

    OK, so it turns out that by default, ReplaySubject uses the Scheduler.CurrentThread.

    If I explicitly set the ReplaySubject to use Scheduler.Immediate or Scheduler.ThreadPool, then it works as expected.

    var replaySubject = new ReplaySubject<string>(1, Scheduler.Immediate);
        replaySubject.OnNext("This can never block... surely?");
    
    var s = replaySubject.First();
    Debug.WriteLine(s);
    

    I still need to investigate how it is that the UI thread gets itself into this mess in my particular scenario but for now, this solves the issue.

    — edited —

    OK, on further investigation, it turns out that the above piece of code for most of the time is initiated on a ThreadPool thread. Even though, when it reaches the code, it is on the Dispatcher thread, Scheduler.CurrentThread puts the ReplaySubject back onto the original ThreadPool thread.

    However, in the scenario where it is breaking, everything starts with the user clicking a button. This is obviously on the UI thread, and when it reaches this piece of code, Scheduler.CurrentThread is now the UI thread, and since we are already on the UI thread, we have a deadlock. First is waiting for the ReplaySubject to pump – but the pump is queued up behind the current action. Subtle and something of which to be aware.

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

Sidebar

Related Questions

I'm encountering the following error at unpredictable times in a linux-based (arm) communications application:
I'm encountering a stupid problem which I just cannot understand. How come that following
I'm encountering an interesting issue with the following code. productObject is a custom object
I am encountering problems writing XML files using PHP. The following is my php
I've been encountering an OverflowException recently within GDI+ via a 3rd party tool which
This site was working properly before I started encountering an error after entering some
I am encountering some unexpected behaviour with a MySQL select query. I am running
I am encountering a strange problem with my script which I am testing to
I am encountering a very strange error for that says the following: Template is
Over the last little while I have been encountering some crashes that are absolutely

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.