How to send messages in the order they were queued, while ensuring that client B does not have to wait until client A has received his message?

I have a simplified producer/consumer pattern implemented below. The code outputs:


1 second delay


1 second delay


1 second delay


What approach can I take here to get rid of the 1-second delay between different letters?

What I’m looking for is something like



1 second delay



It’s important, that clients A and B receive the messages in the order the messages were queued in, but I do not want other clients to be blocked while processing for one client takes a really long time. Using two BlockingCollections and two consumer threads is not an option, because the user count is dynamic.

using System; using System.Collections.Concurrent; using System.Threading.Tasks;  namespace ConsumerProducer {     public enum ClientId     {         A,         B     }      class WebSocketMessage     {         public ClientId ClientId { get; }          public WebSocketMessage(ClientId clientId)         {             ClientId = clientId;         }          public async Task LongRunningSend()         {             Console.WriteLine(ClientId);             await Task.Delay(TimeSpan.FromSeconds(1));         }     }      class Program     {         public static BlockingCollection<WebSocketMessage> Messages = new BlockingCollection<WebSocketMessage>();          static async Task Main(string[] args)         {             var consumer = Task.Run(async () =>             {                 foreach (var message in Messages.GetConsumingEnumerable())                 {                     await message.LongRunningSend();                 }             });              ClientId clientId = ClientId.B;             while (true)             {                 // Flip between A and B                 clientId = clientId == ClientId.A ? ClientId.B : ClientId.A;                  Messages.Add(new WebSocketMessage(clientId));                  await Task.Delay(TimeSpan.FromMilliseconds(100));             }         }     } } 

How long should the user wait before providing reassurance?

I have an application with user login. When a user logs in for the first time, I show them a screen similar to this while the login process completes:

Loading animation with "Loading" text

The user’s access must be validated before they can access any part of the app so it makes sense to block their access while we wait.

The problem is that, due to reasons out of my control, authentication can take anywhere between 3 seconds and 1 minute, because of the backend identity provider. So this icon is on the screen for a long time.

During testing, I’ve noticed that users start to feel like something is broken and want to reload/leave the page after a bit of waiting when authentication is slow.

I want to supplement the “Logging you in…” text after the user has been waiting for a while by adding in “…this can take a while. Please do not navigate away or reload the page.”

How long should I wait to present this additional “reassurance” to the user? Also, is there a better way to comfort the user that everything is working, just taking a while?

Note: I did see this question, which answers a related question of “how long should I wait to show the initial loading indicator to a user?” – not “how long should I wait to supplement the initial loading indicator?” – Loading time and page loader display (when to show)

when to use “wait” and when “busy” mouse cursor

I am developing a desktop application with Qt framework. When there is a task running which causes the UI to be blocked for a while, I would like to use a mouse cursor indicating that the user should wait until the task is finished. There are two cursors available – “wait” cursor and “busy” cursor. What is the difference from the UX perspective. What are the rules when to use one or the other?

enter image description here

Best practice on Web Chat “please wait” messaging

We are currently integrating a web chat functionality on a utilities website, where customers can query their bill, or changing plans etc. with their electricity bills. (this will be available to all customers whether they are logged in or not).

The web chat will sit top right on all paged, and when clicked, will initiate a web chat sessions. In the event of a bottleneck of chats starting, we need to design a pre-screen before the chat initiates with an agent. I cannot find any best practice information our there, so my thought was to provide the following while the user waits:

  • An apology message saying that chat agents are busy.
  • Current wait time: XX minutes.

Would this be considered an overshare of information to the customer? or is the visibility and transparency appreciated and considered good Ux? Any hats thrown into the ring on this one are much appreciated! A brief mockup is something I put together below as a first pass:

enter image description here

SharePoint Designer Workflow – Wait for Field Change help

i’m fairly new to SharePoint and i’m having some trouble trying to create a fully functional workflow for a certain job in SP Designer and was hoping somebody may be able to come up with a solution?

Basically the process needs to go like this:

A staff member uploads a document into a document library.

The document is then required to be marked as “Approved”, “Rejected” or “Referred” after being reviewed by a committee of Admin staff.

(There is a data column with those 3 status options set up as a drop down list when editing the properties of the document that will allow an admin to change the status.)

Depending on the whether the document has been Approved, Rejected or Referred, it will be copied into one of 3 different folders (Approved) (Rejected) (Referred) and then deleted from the initial folder.

On SPD, I have created a workflow which looks like this: enter image description here Currently this works just fine using the Wait for Field Change action, but ONLY if the status is Approved.

I cannot seem to figure out how to add an OR statement or run this action in parallel with another but for the Rejected or Referred Statuses? Adding another stage does not work since the workflow does not move forward unless the document is Approved as per the first stage.

How can i modify this workflow so that IF the selected status is Rejected or Referred the document can be copied to its associated folder as with Approved one?

Wait for vSync without swapping buffers with SDL

I am trying to optimize my SDL rendering loop for an immediate mode GUI application that doesn’t need to be redrawn every frame. I have vSync turned on and would like to skip buffer clearing / drawing altogether if the GUI hasn’t changed.

The problem is, swapping buffers without redrawing causes flickering because of double / triple buffering. On the other hand, also skipping the buffer swap causes the program to run full throttle because the waiting is effectively done in SDL_GL_SwapWindow.

Ideally I would need some kind of function that waits for vSync without swapping buffers, but I haven’t seen one in the SDL documentation. I’ve tried the following solutions but none are satisfiying:

  • Draw VBOs every frame even if they haven’t been updated. That will reduce load on the CPU but not on the GPU busy, so not ideal.
  • Keep track of which backbuffers are up to date, and only redraw them if they are dirty. This worked in my testing but requires to make some assumptions (the number of backbuffers, and hoping the driver didn’t replace them with fresh ones). So not reliable enough.
  • Manually waiting with a small delay. Probably the most reliable, but still not ideal.

Wait for an element to exist in DOM before clicking it

Here is the problem: some script is injecting some HTML5 elements (actually a button with the #thebutton ID) to the current DOM.

But this is a third party script and I have no control of when this will be injected to the page. I need to click automatically on this button when the button is injected to the DOM. Here is my solution so far.

It’s actually working but I’m not sure on how fine this code is. My first guess is that I may use the clearTimeout() method. Is there anything else I must do?

<script type="text/javascript">     function waitForElementToDisplay(selector, time) {         if (document.querySelector(selector) !== null) {             document.getElementById("thebutton").click();             return;         } else {             setTimeout(function () {                 waitForElementToDisplay(selector, time);             }, time);         }     }     // onload     (function () {         waitForElementToDisplay("#thebutton", 500);     })(); </script> 

Here is a simulated jsFiddle of the whole process: