dispatcher

WCF Dispatcher for outgoing message from client side

I was programming a server side exception management by injecting an IErrorHandler into the ChannelDispatcher and all worked pretty well. I wanted someting similar at the client side to to catch exception say when the server went down unexpectedly (results in channel faults). I know most of the example out there puts all method calls to ...

Reactive Extensions Rx - unit testing something with ObserveOnDispatcher

I've some code in my view model as follows: miService.GetSomething(par1, par2) .ObserveOnDispatcher() .Subscribe(dt => { DoSomething(dt); }); Then in my test, I'm "mocking" my service as follows: miService.Setup(ms => ms.GetSomething(....)) .Returns(Observable.Return(XYZ)); The problem is that due to the ObserveOnDispatcher, ...

C#, WPF, Automatically call Dispatcher.Invoke when needed??

I have a program with a Geospace map embedded into it. The event handling for the map is handled on a separate thread to keep the map responsive (for example, the events that fire when the map is clicked). The problem I am having is when the map fires an event, my program needs to update some things in it's gui, and also call back into ...

Threading 101: What is a Dispatcher?

Once upon a time, I remembered this stuff by heart. Over time, my understanding has diluted and I mean to refresh it. As I recall, any so called single threaded application has two threads: a) the primary thread that has a pointer to the main or DllMain entry points; and b) For applications that have some UI, a UI thread, a.k.a the se...

WPF Dispatcher, Background worker and a whole lot of pain.

Ok this may be really simple but everything I try just seems to hit a brick wall. I have a view model with two properties, which are bound to my WPF form: bool IsWorking {get;set;} ObservableCollection<OtherViewModel> PendingItems {get;set;} I have a method that I call to fetch some new pending items from outlook, however I also wh...

Javascript dispatchEvent

Hey... I'm using Flash a lot and my classes uses EventDispatcher class which allowes me to define custom events of a class. How can I do this in javascript. I would like to do something like this: var MyClass = function() { }; MyClass.prototype = { test : function() { dispatchEvent('ON_TEST'); } }; var mc = new MyClass(); mc.a...

How to do preDispatch forwarding in Zend Framework?

I want to use _forward() in preDispatch after checking if the user is logged in in every controller. The scenario is quite easy: If the user is not logged in, it should be forwarded to loginAction either in the same controller or in another controller. This would cause an infinite loop, as the dispatch process starts over again, callin...

WPF: Transfer non-freezable items from one Dispatcher to another

We load FixedPage objects from an XPS document, process and displays it.The following code does the loading of the FixedPage from a Package: FixedPage fp = null; Package package; // xps package Uri packageUri; // uri of the package in the package store Uri fixedPageUri; // uri of the fixed page ...

MVVM best practice to pass Dispatcher to the ViewModel

I suppose to be able to access the Dispacher that belongs to the View I need to pass it to the ViewModel. Bu the View should not known anything about the ViewModel so how do you pass it? Introduce an Interface or instead of passing it to the instances create a global dispatcher singleton that will be written by the View? How do you solve...

Ensuring that things run on the UI thread in WPF

I'm building a WPF application. I'm doing some async communication with the server side, and I use event aggregation with Prism on the client. Both these things results in new threads to be spawned which are not the UI thread. If I attempt to do "WPF operations" on these callback and event handler threads the world will fall apart, which...

Using WPF UI thread should always ensure STA apartment mode, right?

In my WPF application I communicate asynchronously with a server. The callback will hence not be run in the UI thread, and as I need to do some WPF stuff there (create InkPresenter object) I need it to be run on the UI thread. Well, actually the requirement is that it is run on a thread with STA apartment mode. I tried creating a new thr...

Silverlight Timer problem

Hello, I am developing a Silverlight application with custom animations. I want to update the variable animationCounter every 1 milissecond, so that in one second the value is 1000. I've tried DispatcherTimer and System.Threading.Timer. this way: DispatcherTimer timer = new DispatcherTimer(); (...) timer.Interval = new TimeSpan(0, 0, 0...

Is it considered bad practice to have ViewModel objects hold the Dispatcher?

My WPF application is structured using the MVVM pattern. The ViewModels will communicate asynchronously with a server, and when the requested data is returned a callback in the ViewModel is triggered, and it will do something with this data. This will run on a thread which is not the UI Thread. Sometimes these callbacks involve work that...

How to invoke WPF Dispatcher in Nunit?

I want to test an application which renders a text block with a data field value. I would like to get the actual width and actual height, once the rendering completes. Everything works fine. The problem came first, when I tried to test the application. I'm unable to invoke the dispatcher from the test project. Following is the code. ...

Getting the right WPF dispatcher in a thread.

Hi, In the constructor of an object i need to create a WPF mediaElement object: m_videoMedia = new MediaElement(); but the class can also be instantiated from a other thread so i need to use Dispatcher.Invoke(DispatcherPriority.Normal, (Action)(() => { m_videoMedia = new MediaElement(); })); But how can I get the right dispa...

wpf how to return a value with dispatcher.invoke

Hi! Anyone knows how to return a value from Dispatcher.Invoke in WPF? I want to return the selected index for a combobox. Thanks! ...

Problem with Google Analytics for Android : "Dispatcher thinks it finished, but there were 543 failed events"

Anyone know how to solve this problem? 03-23 13:03:20.585: WARN/googleanalytics(3430): Problem with socket or streams. 03-23 13:03:20.585: WARN/googleanalytics(3430): java.net.SocketException: Broken pipe 03-23 13:03:20.585: WARN/googleanalytics(3430): at org.apache.harmony.luni.platform.OSNetworkSystem.sendStreamImpl(Native Met...

Asynchronous Silverlight WCF callback

I've created my own WCF service and I've successfully been able to talk to it via my Silverlight client. I ran into an interesting problem on my asynchronous callbacks though. When my callback is invoked, I can't update any UI controls with the dreaded invalid cross thread access Here's what my callback function looks like private ...

How Dispatcher differs from the background thread ?

How Dispatcher concept in .NET 3.5 in WPF differs from the background thread in .NET 2.0 ? For example what will be difference between statements below: delegate.Invoke/BeginInvoke AND this.dispatcher.Invoke/BeginInvoke ...

C# Thread-safe Extension Method

Hello All, I may be waaaay off, or else really close. Either way, I'm currently SOL. :) I want to be able to use an extension method to set properties on a class, but that class may (or may not) be updated on a non-UI thread, and derives from a class the enforces updates to be on the UI thread (which implements INotifyPropertyChange...