Menu
  • HOME
  • TAGS

Issue calling something on the UI Thread from inside a callback in c++/cx

visual-studio,asynchronous,dispatcher,c++-cx,ui-thread

Declared the context like this: App2::MainPage^ context; Then set it in the MainPage function: MainPage::MainPage() { InitializeComponent(); media = this->player; context = this; } And then I did it this way inside the VideoCapturerSampleCallback: void VideoCapturerSampleCallback(struct LmiVideoCapturer_* capturer, const LmiVideoFrame* videoFrame, LmiVoidPtr userData) { App2::MainPage^ ctx = context;...

c# wpf dispatcher.beginInvoke freeze

c#,wpf,freeze,dispatcher

Always be wary of Dispatcher.CurrentDispatcher as that will will return an object for dispatching on the CURRENT thread - which may not be the UI. You want (and generally almost always want) the UI thread dispatcher. You can get that through Application.Current.Dispatcher Which always returns the UI thread dispatcher. Its...

Weird Thread exception when using Dispatcher.BeginInvoke in a thread

c#,multithreading,dispatcher

SolidColorBrush is a dependency object - and you're creating it in the non-UI thread, then trying to use it in the UI thread. Try this instead: Action action = () => { SolidColorBrush scb = new SolidColorBrush(Color.FromRgb(21, 21, 21)); Background.Background = scb; }; Dispatcher.BeginInvoke(action); Or of course just in one...

Write PowerShell Output (as it happens) to WPF UI Control

wpf,powershell,dispatcher,runspace

Out of curiosity, have you considered that instead of PowerShell firing up WPF and displaying some output, it should be the other way around? Perhaps you should be invoking PowerShell from within a WPF application, and capturing the output to be displayed? http://www.codeproject.com/Articles/18229/How-to-run-PowerShell-scripts-from-C...

Does Dispatcher.BeginInvoke queues the call if it is called from the same thread?

c#,.net,dispatcher,begininvoke

It gets queued to be executed after your running code in the Dispatcher thread and all other queued BeginInvoke's finish executing

WinRT CoreDispatcher RunAsync and closures

c#,windows-runtime,dispatcher,synchronizationcontext

I don't think you need to worry about it. Using a closure is likely to be just fine; I doubt you'll observe any significant performance decrease. Note that in other cases where you can pass parameters to the invoked method, you still wind up with an allocation. At a minimum,...

Calling the pose triggered event using Myo arm band

c#,wpf,events,dispatcher,myo

I compare the sample code from GitHub and your. Did you forget to call pose.Start()? var pose = HeldPose.Create(e.Myo, Pose.Fist); pose.Interval = TimeSpan.FromSeconds(0.5); pose.Start(); //this??? pose.Triggered += Pose_Triggered; ...

In Windows phone, in a added c# class dont work dispatcher

windows-phone-8,dispatcher

You could use this snippet : SynchronizationContext cont = SynchronizationContext.Current; cont.Post((foo) => {}, null ); Hope this helps you. ...

how to properly call callback on dispatcher.begininvoke?

c#,dispatcher

The answer is: nothing. There are three possible approaches: 1.) You can decide that it is not important to wait for the operation to be executed. If so, then you are choosing the fire and forget strategy. 2.) You can decide that you want a synchronous request, so you await,...

Python dispatcher as tkinter Button command/eventlistener

python,tkinter,dispatcher,sender

I don't know anything about dispatchers, but this is a common problem: you're assigning the result of the function call to command because you're not wrapping it in a lambda. Try: self.calc_button = tkinter.Button(self.bottom_frame,text='Convert', \ command=lambda *args: dispatcher.send(signal = 'valueToConvert', sender=dispatcher.Any, message='Kilo')) ...

symfony2 event dispatcher lazy loading listener

php,symfony2,events,dispatcher,lazy-initialization

You can define it as a Lazy Services adding the relative tag (as described here ) as example: my.handler: class: Acme\AcmeBundle\DependencyInjection\MyHandler lazy: true arguments: - @my.dependency tags: - { name: kernel.event_listener, event: my.event, method: handle } Remember to install the ProxyManager bridge as described in the doc. Hope this help...

WPF Dispatcher VS Winform UI Thread Control Invoke

c#,wpf,winforms,thread-safety,dispatcher

The main reason Dispatcher was introduced in WPF is that WPF isn't WinForms and WinForms class members aren't relevant to WPF objects. They had to do something. Could Microsoft have implemented WPF exactly the same way as they did WinForms? Sure. But WPF is a fundamentally different kind of API,...

Application dispatcher invoke freezes the application

wpf,multithreading,messagebox,dispatcher

Its a deadlock because of the calling code is using the .Result. Using service.ComboListAsync().Result makes the UI thread await for this method to return, when you call Application.Current.Dispatcher.Invoke from within it you are sending a message to the UI thread that is awaiting the return of method itself. You must...

500 server error on ajax calls in typo3 using Eid

ajax,typo3,dispatcher,extbase

I just had to change the file AjaxDispatcher : line 101 to: \TYPO3\CMS\Core\Core\Bootstrap::getInstance();...

Does file extension is same as url extension in Sling

caching,cq5,dispatcher,aem,sling

That Cheatsheet merely describes how a script is selected to render a specific request. It has no relation with the Apache Dispatcher. As I answered in your other question what the dispatcher caches or not caches is defined by the rules you set (except for the mentioned exceptions). The steps...

Dispatcher.BeginInvoke Method 'freezing' after second execution

c#,multithreading,unity3d,dispatcher,begininvoke

You're calling Result on the asynchronous operation. This is going to cause the UI thread to block until the asynchronous operation finishes. The asynchronous operation needs to wait for the UI thread to be free so that the continuation to LoadListingInformationAsync can be scheduled in the UI thread. Both operations...

C# / WPF Updating the UI from another thread created within another class

c#,wpf,multithreading,user-interface,dispatcher

For your question about providing a sample, if there is a worker class like... public class Worker { public Worker(Action<string>action) { Task.Run(() => { int i = 0; while (true) { ++i; Task.Run(() => { action("Current value " + i); }); Task.Run(() => { // doing some work here });...

How to find out what does dispatcher cache?

apache,caching,cq5,dispatcher,aem

The Adobe AEM/CQ5 dispatcher simply takes the response body from requests made into the CQ5 instances and saves them as files that then the httpd can deliver. The dispatcher can be configured to allow requests to be either cached or sent directly to the CQ5 instance. This configuration is done...

CQ5/AEM Dispatcher not retaining charset information

character-encoding,cq5,dispatcher,aem

Indeed the dispatcher caches only the content, with no headers. If the page is loaded from the cache, it'll behave pretty much like any other static file served by the Apache. The dispatcher itself doesn't have any charset configuration, but I think that adding AddDefaultCharset utf-8 to the Apache configuration...

Loading a web image asynchronously

c#,wpf,backgroundworker,dispatcher,bitmapimage

Given that you're using the bitmap's ability to asynchronously load the image you don't need a BackgroundWorker in the first place. Rather than creating a BGW to start an asynchronous operation and wait for it to finish, just use the asynchronous operation directly. All you have to do is update...

Akka Dispatcher Dying

scala,akka,actor,dispatcher

What you are seeing there is actually the thread id of the thread that is running that task on behalf of the dispatcher. This does not mean that you have 65K dispatchers. I think the implication is that it is growing and shrinking the thread pool as needed, and the...

Process Dispatcher Queue / Background Threads with one call

c#,wpf,multithreading,dispatcher

You could check if the dispatcher is idle in order to make sure no operations are present. To do this you could hook into the dispatcher using Dispatcher.CurrentDispatcher.Hooks After this you could add an event handler for hooks.DispatcherInactive += DispatcherInactiveHandler That should tell you if the Dispatcher is currently empty....

Dispatcher Task /Action Completion

c#,wpf,dispatcher

Calling Dispatcher.BeginInvoke does not enable you to perform asynchronous actions on a background thread unless you initialised the Dispatcher object on a background thread. So, instead of using a Dispatcher to do what you want, in order to fetch data on a background thread and then pass that data from...

Using framework event dispatcher to raise domain event

php,events,laravel,domain-driven-design,dispatcher

Lately I favor returning events from domain methods and handling those in the application service layer. Since the application service layer is where you bring together all kinds of infrastructure further processing of the returned events, such as dispatching, can be handled in the application service layer. In this way...

Looking for explaination System.NotSupportedException

c#,wpf,backgroundworker,observablecollection,dispatcher

I love how this site helps solving problems. Most of the answers come after describing problem and carefully looking into it. This time it was fault of sorting method. Went for LINQ and it works again, but maybe someone could explain this anyway :] private void SortCollection (ObservableCollection<Log> collection) {...

No NullPointerException in JSTL when calling methods on null object associated with request object.why?

java,jsp,servlets,nullpointerexception,dispatcher

JSTL nearly always suppresses NullPointerExceptions. There is a brief discussion here and more detail can be found in section 3.6 of the JSTL spec.

Changing color of text in a WPF RichTextBox from a different thread

c#,wpf,richtextbox,dispatcher

You need to push the actual change work back on to the GUI thread. During the startup of your application, you can run: SynchronizationContext ctxt = SynchronizationContext.Current; and then pass that somewhere your multithreaded code can get at it. Then to use it: //Code that determines the color to use...

Why is the dispatcher behaving this way when I pass a parameter?

c#,wpf,dispatcher

Without a good, minimal, complete code example, it's impossible to know for sure what the issue is in your scenario. There's just not enough context here. But most likely, you're simply running into a temporal issue. That is, the delegate invoked by BeginInvoke() is executed asynchronously, at some indeterminate later...

Akka messaging mechanisms by example

routing,akka,dispatcher,event-bus

A dispatcher is basically a thread-pool. Akka uses dispatcher for multiple things (like enqueueing messages in the right mailbox or pick up a message from an actor mailbox and process it). Every time one of these actions need to be performed a thread from the thread-pool is selected and used...

Access to a child object attribute using jstl

spring,java-ee,model-view-controller,jstl,dispatcher

You can use: <jstl:out value="${project.bg.attribute}"/> ...

Dispatcher.DisableProcessing - InvalidOperationException

c#,.net,wpf,dispatcher

Ok so I found where the Dispatcher throws the exception. [UIPermissionAttribute(SecurityAction.LinkDemand,Unrestricted=true)] [SecurityCritical] public static void PushFrame(DispatcherFrame frame) { if(frame == null) { throw new ArgumentNullException("frame"); } Dispatcher dispatcher = Dispatcher.CurrentDispatcher; if(dispatcher._hasShutdownFinished) // Dispatcher thread - no lock needed for read { throw new InvalidOperationException(SR.Get(SRID.DispatcherHasShutdown)); } if(frame.Dispatcher != dispatcher) { throw...

how to check my akka dispatchers defined in config file working or not

scala,configuration,akka,dispatcher

You can always print the thread name from inside an Actor, since thread pools (used by dispatchers) will have proper names you should be able to identify if it's running on the dispatcher you expected it to run. class CheckingThread extends Actor { def receive = { case _ =>...

Calling Asynchronous method after certain time has passed

c#,asynchronous,timer,dispatcher

In async you wait using Task.Delay private async Task<Response> ExecuteTask(Request request) { var response = await GetResponse(); switch(response.Status) { case ResponseStatus.Pending: await Task.Delay(TimeSpan.FromSeconds(2)) response = await ExecuteTask(request); break; } return response; } ...

Mixed use of Task and Dispatcher halts the task

c#,wpf,asynchronous,task,dispatcher

I solved my problem with the help of this blog. What I had to do is to edit the getter of my Dependency property SearchCommand so that it uses the Dispatcher. public ICommand SearchCommand { get { return (ICommand)this.Dispatcher.Invoke( System.Windows.Threading.DispatcherPriority.Background, (DispatcherOperationCallback)delegate { return this.GetValue(SearchCommandProperty); }, SearchCommandProperty); // Instead of this...

Process a call in wpf Application in Main thread

c#,wpf,thread-safety,dispatcher

Unfortunately, the question is not very clear. What issue exists with unit testing that you believe prevents you from using Dispatcher.Invoke()? When you tried using Dispatcer.Invoke() on the call to SetSlotCoordinates(), in what way was there "no success"? Basically, the use of Dispatcher.Invoke() (or its asynchronous sibling, Dispatcher.BeginInvoke() should do...

Calling BeginInvoke from a destructor

c#,.net,wpf,dispatcher

It seems like in this case the object would be destroyed before the delegate in the BeginInvoke fires on the UI thread The finalizer queues work to the UI message loop. The object may finish running its finalizer method before the actual delegate gets invoked on the UI thread,...

WPF context menu won't fully close before data heavy operation

wpf,contextmenu,dispatcher,close

I was able to fix this by disabling the "fading" animation that occurs when opening and closing the context menu by overriding the system parameter that controls popup animation: <PopupAnimation x:Key="{x:Static SystemParameters.MenuPopupAnimationKey}">None</PopupAnimation>...

Program hanging on Dispatcher.Run() c#

c#,multithreading,dispatcher

viewer.BeginInvoke(new Action(() => window.Close())); That isn't good enough to get the dispatcher to stop. Your "viewer" is a Winforms Form, not a WPF window. So the normal shutdown mechanism can't work. You have to help and also tell the dispatcher to quit: viewer.BeginInvoke(new Action(() => { System.Windows.Threading.Dispatcher.CurrentDispatcher.InvokeShutdown(); viewer.Close(); }));...

No mapping found when using BeanNameUrlHandlerMapping in Spring MVC

java,spring,url,spring-mvc,dispatcher

In dispatcher-servlet.xml, you have mapping to controller as: <bean name="/beanurlhandlermapping.html" class="com.fanjavaid.controller.BeanNameUrlHandlerMappingController" /> Make change in index.jsp as: <a href="beanurlhandlermapping.html">Click to test BeanURLHandlerMapping</a> ...

Writing the Dispatcher.Invoke VB.NET

vb.net,dispatcher

Dispatcher.Invoke(Sub() ' CODE End Sub) ...

Wpf Dispatcher Pause and Continue

c#,wpf,dispatcher

Thread t = new Thread(() => { while (true) { if (continueDispatcher) numDone = DoStuff(); Thread.Sleep(50); } }); t.Start(); ...

MVVM Dispatcher UI not responisve

c#,wpf,mvvm,dispatcher

I got the answer: First - I had do put out my "LongTimeStuff" out of the Dispatcher. Second - I had do do: Task.Sleep(1); in my loop and suddenly it works. To idea why but it works!...

Dispatcher not triggered during Myo hub initialization

c#,wpf,user-interface,dispatcher,myo

You get this error because channel and hub are disposed immediately after calling channel.StartListening(); using is a convenient way to dispose object for you, in this case, this is not desired. Please refer to using Statement (C# Reference) for more info. Try these steps to fix the problem. 1. Declare...