ui-thread

Interacting with the UI thread from an Async callback method?

时光怂恿深爱的人放手 提交于 2019-12-19 04:42:10
问题 I have a method that is asynchronously called when System.Net.Sockets.NetworkStream.BeginRead completes. skDelegate = New AsyncCallback(AddressOf skDataReceived) skStream.BeginRead(skBuffer, 0, 100000, skDelegate, New Object) In that callback method, I need to interact with the UI thread. Sub skDataReceived(ByVal result As IAsyncResult) CType(My.Application.OpenForms.Item("frmMain"), frmMain).refreshStats(d1, d2) End Sub This causes an exception after the method completes. (when End Sub is

How do I test Prism event aggregator subscriptions, on the UIThread?

一笑奈何 提交于 2019-12-18 13:07:26
问题 I have a class, that subscribes to an event via PRISMs event aggregator. As it is somewhat hard to mock the event aggregator as noted here, I just instantiate a real one and pass it to the system under test. In my test I then publish the event via that aggregator and then check how my system under test reacts to it. Since the event will be raised by a FileSystemWatcher during production, I want to make use of the automatic dispatch by subscribing on the UIThread, so I can update my UI once

Visual Basic.NET: how to create a thread to update the UI

泄露秘密 提交于 2019-12-17 19:59:16
问题 The usual VB way to handle a computationally heavy task is to put it in a background worker thread, while the main thread keeps handling the UI. Say for whatever reason I needed to do this the other way around: the main thread doing the grunt work and the background one updating the UI. Here's what I have so far. The only problem is, while the UI window (Form1) does get redrawn, you can't interact with it, not even move or resize it (the mouse cursor turns to hourglass and won't click).

Accessing UI thread from Windows Runtime Component throws exception only on Mobile

[亡魂溺海] 提交于 2019-12-13 02:56:43
问题 I have the following problem. I am using a simple Windows Runtime Component to communicate between the application and a WebView . I am doing this according to documentation This is the code for the Windows Runtime Component public delegate void NotifyAppHandler( string str ); [AllowForWeb] public sealed class WebViewInjectionObject { public event NotifyAppHandler OnNotifyApp; public void NotifyApp( string str ) { OnNotifyApp?.Invoke( str ); } } In the OnNavigatedTo method I initialize the

Android updating ui thread elements - best practice?

五迷三道 提交于 2019-12-12 18:49:49
问题 I have an app that shows some measurement values like temperature, speed and so on. I want to stick more or less to the MVC pattern so I got something that receives the values when they appear (from a bluetooth component) and sorts them to the special value handlers. those are supposed to calculate stuff and so on (speed from geo coordinates and so on) and pass the values to the View component, which extends activity and is supposed to print the values. Some of the value handlers will be in

Updating UI during AsyncTask

北城以北 提交于 2019-12-12 02:52:05
问题 How can I edit the views of an activity from an AsyncTask BEFORE the task is complete? I cannot access any of the views from the doInBackground method, and I do not want to wait until the task has completed. Is there a way to go about doing this? Or do I have to create a thread within the doInBackground (which sounds to me would be bad practice) and then access the view on that thread's completion? 回答1: Override this method: protected void onProgressUpdate(Integer... progress) {

RestKit, Core Data, Magical Record, Lots of data and Lagging UI

不羁的心 提交于 2019-12-12 01:54:51
问题 I got an app which stores data about restaurants. Their menu, schedule and so on. Theres ~200 restaurants in the DB by now. The app used to retrieve those places by a single shot, but it was taking too much time to load, so i decided to load the data one by one. On the start app asks the server for an array of place's ids, then get the data via API. I set completion blocks for RK's operations to background queues, but it didn't help. Scrolls are running not smoothy enough and sometimes the

How do I catch an exception in a GUI thread?

时光怂恿深爱的人放手 提交于 2019-12-12 01:35:47
问题 An exception is thrown in a user control based on a picture box, causing it to show the typical error image (red X). Since the GUI thread caught and handled the exception itself, I cannot easily find out where the exception occurred and debug. I'm currently wrapping the whole OnPaint code in a try-catch, and was able to debug the code, but I found it quite tedious so I wondered if there is a way to break into debugger from a GUI thread exception. 回答1: It already works this way by default. The

How to make some Tasks change my WPF controls

你。 提交于 2019-12-11 20:37:36
问题 I want to create a WPF application that does this: The application will have 8 Tasks running together. Each task will be able to ad some strings to a text box shown in the main window. how do I get the tasks all running at the same time, and running on the main UI Thread? (30/04/13:) please see the next code: private void RunTasks(int ThreadsNumber) { int Ratio = NumbersToCheck / ThreadsNumber; for (int i = 0; i < ThreadsNumber; i++) { Task.Run(() => { int counter = 0; int low = Ratio * i;

Android: Updating gridview multiple times after x seconds

风流意气都作罢 提交于 2019-12-11 11:33:35
问题 I am having a problem updating the view in android every x seconds. To get to know how android works I am writing a small game. It has a GameController which holds the game loop. Inside the loop, the logic is executed and afterwards the gui will be informed about the changes. The problem is that the changes cannot be seen in the view. The view stays the same until the game loop finishes and updates then only once. Here is my code (the important parts): GameController.java: IGui gui; public