In this article, I want to take this a little further with another example.I have recently had to go and maintain an old c# Winforms application (yes I know winforms is a little old and considered the new vb6 but the application works and still provides value) that needed some new features adding.Providing a concise sample is mandatory, but it would be nice if you could also figure out the indentation issue. Pete And maybe more about what the problem is, not getting UI, not getting it compiled, not getting Event Monitor. Yes it is easyer to read indented code without blank rows...
when I comment out the "Invoke(new Update Text Callback(Update Text));" it works fine. public partial class Form1 : Form public static class Event Monitor I have an Asynchronus process that is reporting back to the UI at regular intervals.
But for some reason my application just hangs, nothing being written it just hangs. But my suspicion is that even though you're using (you say) a separate thread for the async processing, your Click event handler doesn't return right away but instead waits for the processing to complete.
If you're having trouble understanding what is needed in your sample, you might find Jon Skeet's article useful: are some details in there that I feel differently about, on the whole he describes exactly what I mean when I write "concise-but-complete".
Also, for some reason the code is winding up posted without any indentation.
The code below (from the previous article) would execute a long running task which in this case counts to 5,000,000.
As the task was running, on a set interval, the UI would be updated.
when I comment out the "Invoke(new Update Text Callback(Update Text));" it works fine. With the main GUI thread blocked, there's no way for the call to Invoke() to complete, and thus you get a deadlock.
If you want a better answer, you need to post a concise-but-complete sample of code that reliably demonstrates the problem.
w=150 150w" sizes="(max-width: 287px) 100vw, 287px" / When you load up the application and click the button, nothing happens, and about a minute later, the label updates to say “Counter = 5000000”.
Whilst the application is counting, the user interface becomes completely unresponsive. This is the issue I have been facing in this application that I need to maintain.
The code is much simpler to see what’s going on, but the behaviour is slightly different.