dispatcher

Updating UI components from an async callback

心已入冬 提交于 2019-12-24 02:54:06
问题 Now I know about the Dispatcher and the DispatcherTimer and their benefits. But I've always been under the impression that an async web-service/WCF callback (completed event handler) are automatically handled by the UI thread. But looking at some references online such as the one linked below, it seems this is NOT the case. So the strange thing is that i haven't been using the Dispatcher to update the UI (updating data-bound ObservableCollections) within service completed events, yet I've

System.Windows.Controls.WebBrowser, System.Windows.Threading.Dispatcher, and a windows service

て烟熏妆下的殇ゞ 提交于 2019-12-23 19:35:09
问题 I'm trying to render some html content to a bitmap in a Windows Service. I'm using System.Windows.Controls.WebBrowser to perform the render. The basic rendering setup works as a standalone process with a WPF window hosting the control, but as a service, at least I'm not getting the LoadCompleted events to fire. I know that I at least need a Dispatcher or other message pump looping for this WPF control. Perhaps I'm doing it right and there are just additional tricks/incompatibilities necessary

Advice on using the Dispatcher Priority and Binding

一曲冷凌霜 提交于 2019-12-23 17:35:57
问题 In my application I'm using the idle-time of the UI thread to offload expensive operations as described by MSDN article on the WPF Threading Model. GenerateDataAction = () => { GenerateData(); }; Dispatcher.BeginInvoke(GenerateDataAction, DispatcherPriority.Render, null); In the GenerateDate() method I access an MSSQL database, process the data in, and update bindings on the viewmodel. I have noticed since implementing this that some binding fail to update properly or not at all. I have check

Correct method for using the WPF Dispatcher in unit tests

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-23 08:56:32
问题 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 DispatcherFrame(); PropertyChangedEventHandler waitForModelHandler = delegate(object sender, PropertyChangedEventArgs e) { if (e.PropertyName == "Data") { frame.Continue = false; } }; _myViewModel.PropertyChanged += waitForModelHandler; Dispatcher

no definition for dispatcher

耗尽温柔 提交于 2019-12-23 05:23:54
问题 I'm getting the error 'socketServer.Form1' does not contain a definition for 'Dispatcher' and no extension method 'Dispatcher' accepting a first argument of type 'socketServer.Form1' could be found From private void tbAux_SelectionChanged(object sender, EventArgs e) { this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (ThreadStart)delegate() { textBox.Text = tbAux.Text; } ); } According to the documentation, the Dispatcher class is part of the namespace System.Windows.Threading , which I

Dispatcher.Invoke() on Windows Phone 7?

坚强是说给别人听的谎言 提交于 2019-12-22 09:00:40
问题 In a callback method I am attempting to get the text property of a textBox like this: string postData = tbSendBox.Text; But because its not executed on the UI thread it gives me a cross-thread exception. I want something like this: Dispatcher.BeginInvoke(() => { string postData = tbSendBox.Text; }); But this runs asynchronously. The synchronous version is: Dispatcher.Invoke(() => { string postData = tbSendBox.Text; }); But Dispatcher.Invoke() does not exist for the Windows Phone. Is there

WPF: how to invoke a method in a separate thread with a delay time

谁说胖子不能爱 提交于 2019-12-22 08:45:00
问题 I have a TextBox that user can enter search-term in it. Its bind to string Term property in my view-model . And I want to do a search query when its content changed. But I want to do the query in a separate thread with a delay . e.g. when user type a letter, I want to wait for 0.3 second , and if user change the input within this time (0.3 second), the timer resets and starts again. Otherwise, I start a new thread and do the search query. While query is executing, if user change the term

How do I use Dispatcher.BeginInvoke properly?

删除回忆录丶 提交于 2019-12-22 08:39:40
问题 I have searched almost everywhere on the internet, and I have googled so many times and found so many results, but I still can't find the solution to my problem. I am busy converting an old WinForms application to a new WPF application but I am having trouble with some of the commands. In the Winforms application they use Control.BeginInvoke() and store this in an IAsyncResult object. I have read that the Dispatcher.BeginInvoke() is the WPF equivalent to the Control.BeginInvoke() for WinForms

An unhandled exception of type 'System.Windows.Markup.XamlParseException' occurred in PresentationFramework.dll

感情迁移 提交于 2019-12-22 08:35:09
问题 I'm working on a small application in C# / WPF that is fed by data from the serial port. It also reads a text file containing some constants in order to calculate something. An event handler is made to handle the incoming data when it arrives: _serialPort.DataReceived += new System.IO.Ports.SerialDataReceivedEventHandler(Receive); Here is the Receive handler, along with a delegate that is created in a Dispatcher, to further update the UI. private delegate void UpdateUiTextDelegate(string text

耗时6天-JNOJ江南OJ安装记录

爷,独闯天下 提交于 2019-12-21 21:13:56
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 背景 第一次安装OJ,选了下觉得 JNOJ功能、界面都很好而且作者还一直在维护中 ,于是开始安装。 6天:5个工作日主要是晚上3、4小时。一个周六全天. 手动安装没有成功 就是自己下载MYSQL, MYSQL,NGINX,主要按官方的“environment.md”文档安装LNMP环境 Ubuntu选择最新的Ubuntu server 18.04.3LTS, 当然是VM 虚拟机。 安装没有什么问题,主要是配置后出现运行时的各种问题。 开头4天使用手动一步一步安装,装了4次,出现了几个问题,如: NGINX不能访问, NGINX能访问,但PHP不正常, 数据库不能访问, 最后始终不能登录,看NGINX的error.log记录是PHP访问数据有问题 ,没法解决。都想换其它OJ系统再试试了。再看文档进发现最近3天有一个新的更新,还发现作者放了一个在Ubuntu18.04上全自动成功安装过的脚本叫“ 一键安装脚本 ”。于是就尝试全自动安装。 一键安装脚本 原文说明如下: 在 Linux 环境下安装。判题机是在 Linux 环境下写的,Windows 下无法运行判题机。 搭建 LNMP (或 LAMP) 环境:PHP 7.x、MySQL、Nginx / Apache2 本教程分为 **一键安装脚本**、**手动安装过程*