exergist
exergist
CC#
Created by exergist on 3/18/2023 in #help
✅ Sequentially Queueing and Processing Async Messages
I have a websocket connection between two applications. I need to have one of the applications process received messages sequentially (finish processing first message before starting on second message). The receiving application has a single method where all received messages are processed. Assuming I can asynchronously collect received messages, how can I queue them for sequential processing based on the order they were received? Thank you!
7 replies
CC#
Created by exergist on 1/16/2023 in #help
✅ Quicker Screenshot
I'm trying to quickly capture a screenshot. My current method (when capturing the entirety of a 3440x1440p screen) takes about 60-80ms:
// Capture screenshot
static System.Drawing.Bitmap GetScreenshot(System.Drawing.Rectangle bounds = default)
{
if (bounds == default)
bounds = Screen.GetBounds(System.Drawing.Point.Empty);

System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(bounds.Width, bounds.Height);
using (System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(bitmap))
{
g.CopyFromScreen(System.Drawing.Point.Empty, System.Drawing.Point.Empty, bounds.Size);
}
return bitmap;
}
// Capture screenshot
static System.Drawing.Bitmap GetScreenshot(System.Drawing.Rectangle bounds = default)
{
if (bounds == default)
bounds = Screen.GetBounds(System.Drawing.Point.Empty);

System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(bounds.Width, bounds.Height);
using (System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(bitmap))
{
g.CopyFromScreen(System.Drawing.Point.Empty, System.Drawing.Point.Empty, bounds.Size);
}
return bitmap;
}
Capturing a smaller region of the screen (via bounds) definitely helps. Thanks!!
207 replies