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

SynchronizationContext default behavior in TAP (Task Async Pattern)

According to this If the BackgroundWorker starts another BackgroundWorker from its DoWork handler, then the nested BackgroundWorker doesn’t capture the UI SynchronizationContext However with .NET 4.0 and especially 4.5 onwards, I have seen a…
0
votes
0 answers

how to sync a mobile app's database with main server's database

I have building an app that will help employees collect money from customers according to their balance. The app should be working on offline from internet. And when It becomes online, it should sends its collection records to the main server's…
Arif YILMAZ
  • 5,754
  • 26
  • 104
  • 189
0
votes
3 answers

How do I start a Task with a specific scheduler (eg GUI)

I am trying to create a Task with the TPL. eg: Task.Factory.StartNew(() => DoSomething()); This works fine, but now I want to start it on the gui thread. I can cache the gui scheduler with: _uiScheduler =…
GazTheDestroyer
  • 20,722
  • 9
  • 70
  • 103
0
votes
1 answer

How do I use a SynchronizationContext only in client apps

In my library, I use a SynchronizationContext to enable me easily to raise events on the GUI thread whether the library is being used in a Windows Forms or WPF app. If my class was created on a background thread, the SynchronizationContext is null,…
Mark Heath
  • 48,273
  • 29
  • 137
  • 194
0
votes
1 answer

AsyncOperationManager in a .net component for windows service

We have developed a .Net component which works great for WinForms. This component is using a SynchronizationContext to raise events from the underlying threads marshalling to the UI thread (of course the component would get the…
-1
votes
1 answer

Is there a technical reason to pass state via a pass-thru callback argument, or capture it via a closure?

While reviewing code last night I found this code. Of note, state is captured via the lambda which executes the generic-typed callback action. public static void Post(TState state, Action callback){ …
Mark A. Donohoe
  • 28,442
  • 25
  • 137
  • 286
-1
votes
2 answers

Is it possible to test if a method is running with a captured SynchronizationContext when started by a Task?

I might be missing the answer somewhere, or it's something trivial, but I haven't found it. Here's effectively what I'm trying to accomplish in code: public static async Task CapturesContext() { await Task.Run(() => DoWhatever()); } public…
Zer0
  • 7,191
  • 1
  • 20
  • 34
-1
votes
1 answer

Passing Multiple Parameters to SendOrPostCallback in a SynchronizationContext

This relates to my previous post here, where I asked why I should use SynchronizationContext's .Send or .Post, over just a regular .Invoke or .BeginInvoke on my main UI Form. My issue is that the delegate I used to use with Invoke is associated with…
Anders
  • 580
  • 8
  • 17
1 2 3
11
12