dispatcher

Clever event accessors - to fire handlers on the thread they were registered?

风流意气都作罢 提交于 2019-12-25 03:51:07
问题 Have just had an idea, I haven't seen it before, wondering if you guys thought it was a good idea, if it exists, any common pitfalls etc. - and also how to implement it. There are several times I've found myself subscribing to an event from the UI thread that will be called from a different thread - for example, notification of a service call completing. 'My' idea would be to store the current Dispatcher in the add block along with the handler delegate, then when the event is 'fired', perform

Dispatcher.Invoke to update UI Control

。_饼干妹妹 提交于 2019-12-25 02:38:16
问题 I have a .Net 4.0 class that has a custom event handler ( StatusChanged ). I am trying to consume this class via a thread. I don't have the luxury of using BackgroundWorker because libraries I use do not support multi thread apartment state. One of the parameters in the StatusChanged delegate is a string. In the UI, a button click initializes a thread that uses my class. I am trying to make it so a UI control (WPF) gets updated to be the StatusChanged string parameter when StatusChanged event

Asynchronous Silverlight WCF callback

为君一笑 提交于 2019-12-24 23:12:16
问题 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 void GetTimeCallBack( object sender, Talk.ClientBase<IService>.ClientEventArgs e ) { lblDisplay.Text = e.Object.ToString(); } A quick google search showed me that I

DispatcherObject inheritance and usage…what am I not getting?

℡╲_俬逩灬. 提交于 2019-12-24 19:06:52
问题 So here is my code: class Program { static DispatchClass dc; [STAThread] static void Main(string[] args) { dc = new DispatchClass(); Thread th = new Thread(AccessDC); th.Start(); Console.ReadKey(); } private delegate void AccessDCDelegate(object state); static private void AccessDC(object state) { if(dc.Dispatcher.CheckAccess()) dc.Print("hello"); else dc.Dispatcher.Invoke(new AccessDCDelegate(AccessDC)); } } public class DispatchClass : DispatcherObject { public void Print(string str) {

DefaultAnnotationHandlerMapping is deprecated in dispatcher.xml

◇◆丶佛笑我妖孽 提交于 2019-12-24 10:42:49
问题 org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter is deprecated and org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping error in mvc-dispatcher.xml. Why could it be ? please help mee ? code as such the following <bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping" /> <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"/> <bean id="urlMapping" class="org

GUI froze while Dispatcher.BeginInvoke or Task.StartNew

三世轮回 提交于 2019-12-24 10:13:18
问题 NOTE: Depends on this quetion Hi. I have a view-model like this: public class ViewModel { private readonly IPersonService _personService; private readonly ObservableCollection<SearchPersonModel> _foundedList; private readonly DispatcherTimer _timer; private readonly Dispatcher _dispatcher; private CancellationTokenSource _tokenSource; public SearchPatientViewModel(IPersonService personService) { _personService = personService; _foundedList = new ObservableCollection<SearchPersonModel>();

Performance Issues with SharpDX and D3DImage

◇◆丶佛笑我妖孽 提交于 2019-12-24 08:58:05
问题 I have a control that uses D3DImage to host a SharpDX DirectX9 surface and allows use to pan, zoom, and interact with world objects and the result is really awesome. Performance is actually an amazing consistent 60fps EXCEPT when the window is minimized and brought back up or the user locks and then unlocks the screen. When the window regains focus the fps drop to about 25-30fps. I can "fix" the issue by unloading and loading the control back into its container and then BOOM, 60fps. I call

Cannot convert anonymous method to type 'System.Windows.Threading.DispatcherPriority' because it is not a delegate type

南楼画角 提交于 2019-12-24 05:38:12
问题 Can anyone explain what I need to do to get past this error? "Cannot convert anonymous method to type 'System.Windows.Threading.DispatcherPriority' because it is not a delegate type" private void Test(object sender) { base.Dispatcher.BeginInvoke(delegate { //some code }, new object[0]); } Thanks 回答1: If you're using .NET 3.5 SP1 and upwards, then you can add a reference to System.Windows.Presentation.dll and make sure you have using System.Windows.Threading; at the top of the file. It

How to return awaitable (Task?) that waits for an event in Dispatcher Thread

久未见 提交于 2019-12-24 04:09:04
问题 I have threads: UI thread with Dispatcher loop background thread that listens for messages in a queuing framework. when a message is received, an event is fired in the background thread: messageReceiver.Received += (sender, args) => ... In UI thread I would like to await a message, something like this: void ButtonClicked(object sender, RoutedEventArgs e) { await NextMessage(); //should return when messageReceiver.Received is fired } How to implement awaitable NextMessage method, so it does

WPF ICommand CanExecute(): RaiseCanExecuteChanged() or automatic handling via DispatchTimer?

核能气质少年 提交于 2019-12-24 03:10:38
问题 I'm trying to determine the best way to cause ICommands' CanExecute() to be reflected in the UI. I understand that the Dispatcher is the WPF (engine?) that handles UI drawing, and that by default, the Dispatcher evaluates ICommands' CanExecute() method upon instantiation as well as active user interface (clicking the UI, or keyboard input.) Obviously, this is a problem when CanExecute() on any given ICommand changes, but neither mouse nor keyboard input is provided--and so the UI does not