dispatcher

Unable to update UWP UI from code behind using Dispatcher

孤街醉人 提交于 2019-12-11 16:14:30
问题 I have a derived class from MediaTransportControls and trying to disable previous and next track buttons based on some events. I wrote following public class MyMediaTransportControls : MediaTransportControls { public static readonly DependencyProperty IsPreviousTrackButtonEnabledProperty = DependencyProperty.Register( "IsPreviousTrackButtonEnabled", typeof(bool), typeof(MyMediaTransportControls), new PropertyMetadata(false, IsPreviousTrackButtonEnabledChangedCallback)); private static async

How to await the generation of containers in an ItemsControl?

拈花ヽ惹草 提交于 2019-12-11 15:20:26
问题 I have a SettingsWindow , in it there is an audio file selector which has a context menu. Some code accesses the MyAudioFileSelector computed property before it can get the AudioFileSelector because the AudioFileSelector is just inside a DataTemplate of an item in an ItemsControl that has not yet generated its containers at that moment. I tried to deffer the access to MyAudioFileSelector using Dispatcher.BeginInvoke with DispatcherPrority.Loaded , but the item containers are still not yet

The calling thread cannot access this object because a different thread owns it

瘦欲@ 提交于 2019-12-11 15:05:50
问题 I am getting the exception "The calling thread cannot access this object because a different thread owns it" inspite of using Dispatcher.Invoke. Below is the code: _btnImage1 is an instance of ImageButton declared in xaml of LaneImageReview. Note that I used Dispatcher in the RefreshLiveVESImage method below. public partial class LaneImageReview : Page { private void RefreshLiveVESImages(VESImagePackageInfo p_VesImageInfo) { this._btnImage1.RefreshLiveVESImage(p_VesImageInfo); } } public

Dispatcher in WPF apps implementing multiple async Tasks

随声附和 提交于 2019-12-11 13:45:15
问题 In the following MSDN example of the WPF app, which demonstrates async/await implementation of the multiple async Tasks , the Dispatcher object apparently is not used/needed, i.e. asynchronously executed Tasks seem to have direct access to the UI controls (in this case resultTextBox TextBox control - see the line resultsTextBox.Text += String.Format("\r\nLength of the download: {0}", length); ). The app has been tested, performing as expected. However, the question still remains if this

how to use multiple dispatchers in same cherrypy application?

让人想犯罪 __ 提交于 2019-12-11 13:33:48
问题 I have a cherrypy application like this: import cherrypy from controllers import UsersController class Root(object): exposed = True def index(self): return 'welcome' if __name__ == '__main__': root = Root() root.users = UsersController() cherrypy.tree.mount( root, '/', { '/users' : {'request.dispatch' : cherrypy.dispatch.MethodDispatcher()} } ) cherrypy.engine.start() cherrypy.engine.block() Now I wish to use MethodDispatcher() for providing REST api to /users resource and I want a default

Does using dispatcher.Invoke make my thread safe?

与世无争的帅哥 提交于 2019-12-11 13:16:49
问题 In my WPF app I have a long running upload running, which raises progress events as it goes which updates a progress bar. The user also has a chance of cancelling the upload, or it might go wrong. These are all async events, so they need to be executed using Dispatcher.Invoke in order to update the UI. So the code looks like this, ish: void OnCancelButtonClicked(object sender, EventArgs e) { upload.Cancel(); _cancelled = true; view.Close(); view.Dispose(); } void OnProgressReceived(object

InvalidOperationException: dispatcher processing is suspended on ImageOffsetProperty

空扰寡人 提交于 2019-12-11 12:53:56
问题 I am using C# and WPF and am trying to slide an image strip along the screen. I am being honest, I got the code from some code sample on the Internet and took the parts I needed from it. public double ImageOffset { get { try { return (double)this.Dispatcher.Invoke( System.Windows.Threading.DispatcherPriority.Background, (DispatcherOperationCallback)delegate { return GetValue(ImageOffsetProperty); }, ImageOffsetProperty); } catch { return (double)this.GetValue(ImageOffsetProperty); } } set {

Get all windows from all threads

蓝咒 提交于 2019-12-11 12:25:05
问题 I start in my application some threads like this.Thread = new Thread(() => { System.Windows.Threading.Dispatcher.CurrentDispatcher.BeginInvoke(new Action(() => { ... ... })); System.Windows.Threading.Dispatcher.Run(); }) { IsBackground = true, Name = Constants.SPECIAL_UI_THREAD_NAME}; this.Thread.SetApartmentState(ApartmentState.STA); this.Thread.CurrentCulture = Thread.CurrentThread.CurrentCulture; this.Thread.CurrentUICulture = Thread.CurrentThread.CurrentUICulture; this.Thread.Start();

How to use the dispatcher to load multiple images [closed]

六月ゝ 毕业季﹏ 提交于 2019-12-11 11:46:52
问题 This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 8 years ago . I have the same problem as stated in this question, and the question is answered and the answer seems also to (theoretically) work in my problem. But I

WPF UI update from a timer thread

做~自己de王妃 提交于 2019-12-11 06:46:12
问题 Within the App I display banners that rotate as time progresses or when user clicks next/previous. 1) I need to update an UI element within Timer.Elapsed method. From what I found, it seems that timer ticks are executed on their own thread and element's dispatcher should be use to update the UI. ( (Image)BannerPanel.Content ).Dispatcher.Invoke( new Action( () => { ( (Image)BannerPanel.Content ).Source = GetImage( new Uri( banner.Uri, UriKind.Absolute ) ); } ) ); but that throws an