dispatcher

Struts2里的Result

狂风中的少年 提交于 2019-12-18 10:52:28
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> Result 一、Result基础 Result是什么和能干什么? 简单的说,Result是当Action处理完数据后返回的一个字符串,它指定了下一个页面的位置。比如: <action name="action_1" class="struts2.com.test.ActionSupport_1"> <!--suppress Struts2ModelInspection --> <result name="success">hellowordactionsuccess.jsp</result> <!--suppress Struts2ModelInspection --> <result name="input">hellowordactionerror_1.jsp</result> </action> action返回的字符串对应的就是result标签里的name属性值。 Result有什么 对于Result 在struts2中,预定义了以下一些Result的字符常量: SUCCESS:表示Action执行成功,显示结果视图给用户,值为字符串“success”。 NONE:表示Action执行成功,不需要显示视图给用户,值为字符串“none”。 ERROR:表示Action执行失败,显示错误页面给用户

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

一世执手 提交于 2019-12-18 09:23:40
问题 I've been reading blogs about writing to the UI from different runspaces (http://learn-powershell.net/2012/10/14/powershell-and-wpf-writing-data-to-a-ui-from-a-different-runspace/). I'm basically trying to make it so I can click a button in the UI and run a PowerShell script and capture the output of that script as it happens and update the WPF UI control without freezing up the UI. I've tried a basic example of just writing some output directly, but it seems to hang the UI. I'm using

Dispatcher to Thread relationships in WPF

☆樱花仙子☆ 提交于 2019-12-17 17:49:08
问题 It is not entirely clear to me how many Dispatchers there are in an application and how they are related to, or referenced from Threads. As I understand it, a WPF application has 2 threads (one for input, the other for UI) and 1 dispatcher (associated to the UI-Thread). What if I create another thread - let's call it "worker thread" - when I call Dispatcher.CurrentDispatcher on the worker thread, which dispatcher will i get? Another case: Assume a console application with 2 threads - the main

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

不打扰是莪最后的温柔 提交于 2019-12-17 09:34:00
问题 Whenever I refresh a label, I got this error: The calling thread cannot access this object because a different thread owns it. I tried to invoke but it's failed. I'm using WPF Form. delegate void lostfocs(string st); private void imgPayment_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { Thread t = new Thread(modi); t.Start(); } void modi() { try { label1.Content = "df"; } catch { lostfocs ld = new lostfocs(up); // ld.Invoke("df"); object obj=new object(); ld.Invoke("sdaf"); } }

c# - Volatile keyword usage vs lock

怎甘沉沦 提交于 2019-12-17 06:27:35
问题 I've used volatile where I'm not sure it is necessary. I was pretty sure a lock would be overkill in my situation. Reading this thread (Eric Lippert comment) make me anxious on my usage of volatile: When should the volatile keyword be used in c# ? I used volatile because my variable is use in a Multithreaded context where this variable could be accessed/modified concurrently, but where I can loose an addition without any hurts (see code). I added "volatile" to make sure that there is no miss

【JAVA】启动一个最简单的Java main程序时有多少个线程被创建

你。 提交于 2019-12-14 18:24:11
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>>  在java中,启动一个简单的main程序,并不是只是单单创建了一个main线程而已,JVM会自动创建一些辅助用的线程,主要有以下几个:   Attach Listener:Attach Listener线程是负责接收到外部的命令,而对该命令进行执行的并且吧结果返回给发送者。通常我们会用一些命令去要求jvm给我们一些反 馈信 息,如:java -version、jmap、jstack等等。如果该线程在jvm启动的时候没有初始化,那么,则会在用户第一次执行jvm命令时,得到启动。   Signal Dispatcher:前面我们提到第一个Attach Listener线程的职责是接收外部jvm命令,当命令接收成功后,会交给signal dispather线程去进行分发到各个不同的模块处理命令,并且返回处理结果。signal dispather线程也是在第一次接收外部jvm命令时,进行初始化工作。   Finalizer:这个线程也是在main线程之后创建的,其优先级为10,主要用于在垃圾收集前,调用对象的finalize()方法;   Reference Handler:VM在创建main线程后就创建Reference Handler线程,其优先级最高,为10,它主要用于处理引用对象本身(软引用、弱引用、虚引用

Getting the current page when receiving a toast notification (WP8.1 Silverlight, receiving WNS toast notification)

对着背影说爱祢 提交于 2019-12-13 19:26:29
问题 I have an event that fires when the app is live and I receive an notification CurrentChannel_PushNotificationReceived . In this function I want to find out which page is currently displayed to know if the notification should update content on the page. The question is therefore twofold, how to know which page is currently displayed and interact with the toast notification. Update The issue is that I cannot interact with the elements because of clash with the OS threading (Dispatcher).

Unit Testing CompositePresentationEvent when using the Dispatcher

余生长醉 提交于 2019-12-13 18:08:05
问题 Im using the Prism/Composite Application Library and trying to unit test some code that subscribes to a CompositePresentationEvent using the EventAggregator. The code that is raising the event is raising it on another thread so I am subscribing to the event using ThreadOption.UIThread. When the event raises the callback it uses the application dispatcher to put it onto the UI thread. This is fine during normal execution but during a unit test there is no dispatcher. The code in

Catch C# WPF unhandled exception in Word Add-in before Microsoft displays error message

放肆的年华 提交于 2019-12-13 16:16:23
问题 I am developing a Microsoft Word Add-in using C# and WPF. In one of my windows, a helper class is throwing an exception in an event. I want the exception to bubble up to the window level so that I can catch it and display an error message to the user. Because it's in an event in the helper class, I can't just surround a method call in the window code with a try/catch block to catch it. Application.Current returns null so I cannot use the Application Dispatcher. I can use Dispatcher

Why do I need to call Dispatcher.BeginInvoke() to allow a visual to properly bind before printing?

流过昼夜 提交于 2019-12-12 21:46:28
问题 I have a UserControl with a fixed size of 850x1100 to give me the same aspect ratio as a letter-sized piece of paper. I display this in my window inside a Viewbox , and it acts much like a print preview. The control inherits my window's DataContext, and when it's displayed on the screen, all the bindings work and it looks wonderful. I've written the code below in my window's code behind (I feel it's a totally view-oriented operation) to attempt to print it. If I execute this code as written,