Questions tagged [synchronizationcontext]

A .NET target to dispatch some work to. In winforms and WPF this is usually to the main UI thread.

A .NET target to dispatch some work to. In winforms and WPF this is usually to the main UI thread.

References

173 questions
0
votes
1 answer

c# make UI calls when TCPClient receives data async

I have a Forms app and a Console server app connected with TCPClient. The Forms app opens up a dialog for user authentication, when user clicks the Login button, a request is sent to the server. The server then responds if the login credentials were…
Tsaras
  • 455
  • 2
  • 4
  • 18
0
votes
1 answer

Background Thread messages to UI Thread cache and not pushed to UI till background process complete

I've read many previous posts on multithreading in .NET, and tried a number of approaches but I'm struggling to get my specific case and c#.NET code to behave. My code is designed to run long-running processes in the background and report ongoing…
0
votes
0 answers

relationship between scope and synchronization context

How do scope and synchronization context relate? With regards to this Search() method running in our WPF GUI thread: private void Search() { const int CPUs = 2; var doneEvents = new ManualResetEvent[CPUs]; // Configure and launch…
Marcin
  • 131
  • 6
0
votes
1 answer

Set HttpContext.Current is not the same in continuation of await

From this answer from Stephen Cleary, I understand that the HttpContext flows with the SynchronizationContext. Therefore, given the following piece of code: public async Task Index() { var outerContext =…
0
votes
1 answer

UI thread waits for "await client.SendAsync(request).ConfigureAwait(false)" to finish before moving to another url

Client starts some action via button. In controller its async method: async public Task CreatePresentation that contains line using (var response = await client.SendAsync(request).ConfigureAwait(false)). Lets say this line takes 10s to…
0
votes
0 answers

How to access a Realm instance in the same thread that it was created in .NET (Xamarin-UWP)?

I am working on the migration from SQLite/WebApis to Realms in an App in Xamarin Forms. This application manages a messaging service (Chat through SignalR). The problem that has arisen is when a message is received, which I try to store in a…
Ivanrlg
  • 79
  • 1
  • 11
0
votes
1 answer

Run task with current SynchronizationContext not resume execution after await methods

I need to run task with current SynchronizationContext. I do it using Task factory: Task.Factory.StartNew(async () => { ... var result = …
0
votes
0 answers

Consider Calling ConfigureAwait on the awaited task

I'm developing an web API using CQRS pattern. I have a command to Create Author. Here is my Command Handler: internal sealed class AddCommandHandler : ICommandHandler { private readonly IUnitOfWork _unitOfWork; …
fingers10
  • 6,675
  • 10
  • 49
  • 87
0
votes
0 answers

Cannot receive real time data via synchronizationContext.Post() and progress.Report() in async Task

I try to collect the real time output from "public async Task RunProcessAsync()" and send to Form1 via "synchronizationContext.Post()" and "progress.Report()" to process there, for debug purpose, timestamps are added both in the output and received…
0
votes
0 answers

How to make sure HttpContext.Current is not lost during IdentityServer notifications

I have a scenario where I am using a notification event in my client in the setup code is very simple as follows. This is a AspNet Mvc 4.72 client that uses AspNetCore IdentityServer4: app.UseOpenIdConnectAuthentication(new…
jwize
  • 4,230
  • 1
  • 33
  • 51
0
votes
1 answer

Where is asynchronous continuations are queued in ASP.NET Core?

On legacy ASP.NET, the continuation of asynchronous method is queued to the request context (AspNetSynchronizationContext). But on ASP.NET Core, there is no such a SynchronizationContext (contextless). So, where are asynchronous continuations…
tuq
  • 1,328
  • 2
  • 11
  • 21
0
votes
2 answers

Why doesn't the SynchronizationContext flow here?

In my Asp.Net WebApi controller (framework version 4.6.1) I have the following code: [Route("async_test_2")] public async Task AsyncTest2() { TelemetryDebugWriter.IsTracingDisabled = true; var…
Triynko
  • 18,766
  • 21
  • 107
  • 173
0
votes
0 answers

C# - SynchronizationContext vs multi thread?

I want to optimize My server side speed and performance to manage clients, I think I have two way to mange them: 1.Create manually one thread per client connection 2.create SynchronizationContext per client (this will manage threads on…
Ali Yousefi
  • 2,355
  • 2
  • 32
  • 47
0
votes
0 answers

Any generally accepted pattern for storing a SynchronizationContext or other view model object to marshall onto the Ui thread?

My question has changed now: I am looking for a "correct" pattern to be able to store a SynchronizationContext or something else in the view model; so that I can marshall external invokers back onto the window's thread. My goal: Get a platform…
Steven Coco
  • 542
  • 6
  • 16
0
votes
1 answer

What Exactly Happens in C# When PictureBox.Visible Is Set to True?

I'm creating a WinForms app with picture boxes which are disabled and not visible by default. When I click on a radio button in my form, I want the picture boxes to appear and immediately after that I want something to be drawn over them: // the…
honzukka
  • 3
  • 3