Questions tagged [dispatcher]

In WPF and Silverlight, Dispatcher is an object that is used to execute work on a specific thread. In another meaning, dispatcher defines an object that receives requests from the client and sends them to any resource (such as a servlet, HTML file, or JSP file) on the server.

In and , Dispatcher is an object that is used to execute work on a specific .

In another meaning, a dispatcher object can forward a client's request to a resource or include the resource itself in the response back to the client. A resource can be another servlet, or an HTML file, or a JSP file, etc.

1296 questions
10
votes
3 answers

Application.Current.Shutdown() vs. Application.Current.Dispatcher.BeginInvokeShutdown()

First a bit of background: I have a WPF application, which is a GUI-front-end to a legacy Win32-application. The legacy app runs as DLL in a separate thread. The commands the user chooses in the UI are invoked on that "legacy thread". If the "legacy…
Daniel Rose
  • 17,233
  • 9
  • 65
  • 88
10
votes
2 answers

Portable class library equivalent of Dispatcher.Invoke or Dispatcher.RunAsync

In .NET, Windows 8 and Windows Phone 7 I have code similar to this: public static void InvokeIfRequired(this Dispatcher dispatcher, Action action) { if (dispatcher.CheckAccess()) { action(); } else { …
9
votes
2 answers

Correct method for using the WPF Dispatcher in unit tests

I am trying to follow the suggestions from Using the WPF Dispatcher in unit tests in order to get my nUnit test to run. When I write my unit test as below, it works: [Test] public void Data_Should_Contain_Items() { DispatcherFrame frame = new…
Flack
  • 5,727
  • 14
  • 69
  • 104
9
votes
2 answers

use lambda expressions as parameter in Dispatcher.Invoke()

I have such problem : there is some method private List GetStatusList() { return (List)GetValue(getSpecifiedDebtStatusesProperty); } To invoke it in main thread - I use `delegate List
vklu4itesvet
  • 375
  • 1
  • 4
  • 15
9
votes
3 answers

UI Thread Block

I have created a simple WPF Application and added a button to the default window. When I click on the button, a simulated long working method(simulated using a Thread.Sleep(15000) is called. I am trying to make the button execute asynchronously…
fin
  • 1,275
  • 4
  • 18
  • 34
9
votes
1 answer

how to give callback function to the Dispatcher.BeginInvoke

I need to use callback function to do some post procesing tasks when the function started with the Dispatcher.BeginInvoke finishes. However i could not find any parameter in Dispatcher.BeginInvoke to accept a callback. Is it possible to give a…
logeeks
  • 4,849
  • 15
  • 62
  • 93
9
votes
4 answers

Invoking WPF Dispatcher with anonymous method

I just realized in a C# .Net 4.0 WPF background thread that this doesn't work (compiler error): Dispatcher.Invoke(DispatcherPriority.Normal, delegate() { // do stuff to UI }); From some examples I found out that it had to be casted like this:…
djk
  • 943
  • 2
  • 9
  • 27
9
votes
4 answers

Multi-threaded WPF Application: Dispatcher Invoke. A more efficient way?

I am using .NET 3.5 . I am making a WPF application for a project and I was just looking a bit of insight regarding the Dispatcher and multithreading. An example of my program: Application.Current.Dispatcher.Invoke(DispatcherPriority.Background, new…
Sparky
  • 415
  • 2
  • 5
  • 13
9
votes
2 answers

Practical use for Dispatcher.DisableProcessing?

What is a common real life use for Dispatcher.DisableProcessing in WPF? Can I use it to suspend rendering and layout when I build a complex UI in code?
bitbonk
  • 48,890
  • 37
  • 186
  • 278
9
votes
2 answers

UWP Windows 10 app crashes in release mode but works fine in debug mode

My UWP app is crashing in Release mode and works fine in Debug mode but I can't put my finger on what the issue is but I know it's related to a combination of raising an event from System.Threading.Timer and MVVMLight. I created an new dummy…
Thierry
  • 6,142
  • 13
  • 66
  • 117
9
votes
2 answers

Windows processes in kernel vs system

I have a few questions related to Windows processes in kernel and usermode. If I have a hello world application, and a hello world driver that exposes a new system call, foo(), I am curious about what I can and can't do once I am in kernel mode. For…
teleball
  • 4,602
  • 6
  • 37
  • 38
8
votes
2 answers

backbone.js - working with the event dispatcher var dispatcher = _.clone(Backbone.Events)

In backbone.js documentation it says: To make a handy event dispatcher that can coordinate events among different areas of your application: var dispatcher = _.clone(Backbone.Events) Can anyone explain how to implement the dispatcher to communicate…
joafeldmann
  • 246
  • 4
  • 14
8
votes
3 answers

ListView not updated correctly with ObservableCollection

I'm currently using an observable collection to store my data objects for a ListView. Adding new objects to the collection works just fine, and the listView updates properly. However when I try to change one of the properties of an object in the…
user793491
  • 193
  • 2
  • 7
8
votes
4 answers

How to determine whether a class is instantiated within a console application or wpf?

I need to write a wrapper around a third party api that peruses message pumps and hence needs to be handled very differently depending on whether the wrapper is instantiated on a UI thread (such as within a wpf application) or not (such as a…
Matt
  • 7,004
  • 11
  • 71
  • 117
8
votes
1 answer

Dispatcher.Invoke and propagating errors

I have a splash screen for a WPF (using .net 4.5 and mvvmlight) that must perform various load operations in an async manner, showing progress and occasionally asking for user input. When asking for input, I'll create forms/dialogs off the UI thread…
MoSlo
  • 535
  • 5
  • 11