dispatcher

c# wpf Updating UI source from BlockingCollection with Dispatcher

怎甘沉沦 提交于 2020-01-11 14:01:14
问题 Here's my problem. I'm loading a few BitmapImages in a BlockingCollection public void blockingProducer(BitmapImage imgBSource) { if (!collection.IsAddingCompleted) collection.Add(imgBSource); } the loading happens in a backgroungwork thread. private void worker_DoWork(object sender, DoWorkEventArgs e) { String filepath; int imgCount = 0; for (int i = 1; i < 10; i++) { imgCount++; filepath = "Snap"; filepath += imgCount; filepath += ".bmp"; this.Dispatcher.BeginInvoke(new Action(() => { label1

使用IntelliJ IDEA开发SpringMVC网站(三)数据库配置

ε祈祈猫儿з 提交于 2020-01-10 11:40:54
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 转载请注明出处: Gaussic 。 注:在阅读本文前,请先阅读: 使用IntelliJ IDEA开发SpringMVC网站(一)开发环境 使用IntelliJ IDEA开发SpringMVC网站(二)框架配置 访问GitHub下载最新源码: https://github.com/gaussic/SpringMVCDemo 文章已针对IDEA 15做了一定的更新,部分更新较为重要,请重新阅读文章并下载最新源码。 六、数据库配置 下面,就要通过一个简单的例子,来介绍SpringMVC如何集成Spring Data JPA(由 Hibernate JPA 提供),来进行强大的数据库访问,并通过本章节的讲解,更加深刻地认识Controller是如何进行请求处理的,相信看完这一章节,你就可以开始你的开发工作了。 准备工作: 在src\main\java中新建两个包:com.gaussic.model、com.gaussic.repository,将在后面用上,如下图所示: 1、创建Mysql数据库 本文的讲解使用Mysql数据库,如果使用其它数据库的读者,可以去网上参考其他的配置教程,在此不做太多的叙述。数据库是一个底层的东西,底层的细节对上层的抽象并没有太大的影响,因此,只要配置好数据库

Spring-使用Spring profile 多环境配置管理

北慕城南 提交于 2020-01-07 16:02:38
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 使用Spring profile 多环境配置管理 现象 :在实际项目开发中,由于都存在复杂多变的配置文件(redis、mysql等等),这个时候我们在频繁迭代过程中,需要不断的发布新版本,这个时候就会涉及到运维人员版本的管理。虽然运维也不是吃干饭的,他们也有自己的一套配置文件管理方案,也会经常用到一些比较成熟的软件来代替,实现自动打包,自动发布新产品等。通过运维对配置文件的管理也避免了开发程序员越权控制不该控制的东西(如:生产库地址),但不是所有的项目都能有一个单独的运维来管理的,这个时候就把配置工作交给了程序员。这个时候由于项目配置文件比较多,这个时候我们就要考虑如何给自己设定一个规则,通过这个规则减少我们的维护成本,虽然市面上有很多插件能更好的管理配置文件信息,但基于成本和学习能力,这个时候我们其实可以考虑使用Spring profile,使用Spring profile进行多个环境配置,做到单点控制,就是改动一个地就能进行版本发布了,而不是在本地保存几个版本的配置信息,通过copy方式来解决。接下来就记录一下Spring profile的使用配置方式。 配置方式 : web.xml <context-param> <param-name>spring.profiles.active</param-name

Android using shared preference and Dispatcher activity, to get back to the last activity (after reboot the phone)

人走茶凉 提交于 2020-01-06 19:57:14
问题 I'm using a Shared Preferences to save the state of my application to be able to get to the last activity before my Android Handphone got re-boot-ed. My purpose is when Android system manage the memory and push out my apps, when users re-enter to the apps, they will get to the last Activity and screen of my apps. And this is some of my code : First is DispatcherActivity.java : > package com.lm.rosary; > > import android.app.Activity; import android.content.Intent; import > android.content

Dispatcher.Invoke hangs main window

試著忘記壹切 提交于 2020-01-06 07:44:52
问题 I've created new WPF project, in main window I'm doing: public MainWindow() { InitializeComponent(); Thread Worker = new Thread(delegate(){ this.Dispatcher.BeginInvoke(DispatcherPriority.SystemIdle, new Action(delegate { while (true) { System.Windows.MessageBox.Show("asd"); Thread.Sleep(5000); } })); }); Worker.Start(); } the problem is between those messages MainWindow hangs. How do I get it work asynchronously? 回答1: Because you are telling the UI thread to sleep and you are not letting the

Dispatcher.Invoke hangs main window

梦想与她 提交于 2020-01-06 07:43:51
问题 I've created new WPF project, in main window I'm doing: public MainWindow() { InitializeComponent(); Thread Worker = new Thread(delegate(){ this.Dispatcher.BeginInvoke(DispatcherPriority.SystemIdle, new Action(delegate { while (true) { System.Windows.MessageBox.Show("asd"); Thread.Sleep(5000); } })); }); Worker.Start(); } the problem is between those messages MainWindow hangs. How do I get it work asynchronously? 回答1: Because you are telling the UI thread to sleep and you are not letting the

Loading the list of items asynchronously in a WPF listbox using Dispatcher

一个人想着一个人 提交于 2020-01-04 06:29:13
问题 I am working on creating a WPF solution which uses MVVM pattern to load searched items in a search control asynchronously. The search control which is a WPF usercontrol is created with a textbox to enter search text and search button and a hidden listbox which would be visible when it loads the searched items list in it. This user control is in turn embedded into another WPF view which has a treeview of certain items. This view has a view model in which the logic to load the searched items of

Dispatcher.BeginInvoke problems

五迷三道 提交于 2020-01-01 04:30:06
问题 I'm getting "An object reference is required for the non-static field, method, or property 'System.Windows.Threading.Dispatcher.BeginInvoke(System.Action)'" for this code. private void ResponseCompleted(IAsyncResult result) { HttpWebRequest request = result.AsyncState as HttpWebRequest; HttpWebResponse response = request.EndGetResponse(result) as HttpWebResponse; using (StreamReader sr = new StreamReader(response.GetResponseStream())) { Dispatcher.BeginInvoke( () => { try { XDocument

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

不羁岁月 提交于 2019-12-31 03:58:10
问题 I come from an embedded C background and I am working on my first C# application and I have hit a wall on this and my research is not panning out so I thought I would ask here. Simple app, so far. I have a MainWindow that, among a bunch of other stuff, starts a TCPClient thread on a button click: public partial class MainWindow : Window { .... TCPConnection myCon = new TCPConnection(); .... private void connectButton_Click(object sender, RoutedEventArgs e) { networkListBox.Items.Add(

Spring returns HTTP 405 for every HTTP POST which isn't authorized

℡╲_俬逩灬. 提交于 2019-12-31 03:12:11
问题 It seems like Spring isn't routing/authorizing HTTP POST requests correctly. When I send a HTTP POST request I always get "405 Method Not Allowed" response and this in the log file: org.springframework.web.servlet.PageNotFound - Request method 'POST' not supported The controller allows POST for the URL: @RequestMapping(value = "/mypostreq", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE) @Secured("ROLE_USER") public String mypostreq(@RequestBody String callBody,