I have a while loop that updates the form, while the actual information for the form is updated in a separate thread. The problem is, it is designed like this currently:
while (!quit) {
this.SuspendLayout();
this.BeginInvoke(new InvokeDelegate(UpdateForm));
System.Threading.Thread.Sleep(1000);
this.Update();
this.ResumeLayout(true);
}
UpdateForm just updates the Text properties of 2 labels and exits. I've tried a lot in the past few hours, but this while loop thing has got me... How do I prevent such a deadlock? I've tried various combinations of Threads, Invoke, BeginInvoke, and the like, and nothing has worked. I've went through several tutorials on the topics (all of which dealt with the console), and understood how things worked. I even created my own console app based on what I learned. Windows Forms is a completely different animal from console apps though... Can anybody help or provide suggestions? Note that this isn't homework (I can't imagine doing this for homework...); it is just being done in the pursuit of knowledge! :)
These are awesome, and should hopefully do 2.2 soon. They use a standard MPO fibre optic cable and you can just change the ends to upgrade.
https://www.amazon.co.uk/dp/B0DPWR4BXY
RUIPRO 8K Detachable Pure Fibre Optic Armored HDMI 2.1 Cable 33FT, Ultra High Speed 48Gbps, Support 8K@60Hz 4K@120Hz, Dynamic HDR, eARC
https://ruipro.store/products/ruipro-8k-gen4ak-detachable-pure-fiber-armored-hdmi-cable
I wonder if it is possible to disable it.
Not that I have ring cameras, I do have Blink cameras, which are also owned by Amazon, but I doubt they will put it on them. i also own an Eviz doorbell camera, I hope they don't follow suit and do what Amazon does.
Question
rpgfan
I have a while loop that updates the form, while the actual information for the form is updated in a separate thread. The problem is, it is designed like this currently:
while (!quit) { this.SuspendLayout(); this.BeginInvoke(new InvokeDelegate(UpdateForm)); System.Threading.Thread.Sleep(1000); this.Update(); this.ResumeLayout(true); }
UpdateForm just updates the Text properties of 2 labels and exits. I've tried a lot in the past few hours, but this while loop thing has got me... How do I prevent such a deadlock? I've tried various combinations of Threads, Invoke, BeginInvoke, and the like, and nothing has worked. I've went through several tutorials on the topics (all of which dealt with the console), and understood how things worked. I even created my own console app based on what I learned. Windows Forms is a completely different animal from console apps though... Can anybody help or provide suggestions? Note that this isn't homework (I can't imagine doing this for homework...); it is just being done in the pursuit of knowledge! :)
Link to comment
https://www.neowin.net/forum/topic/611209-c-updating-a-label-in-real-time-without-deadlocking-form/Share on other sites
4 answers to this question
Recommended Posts