c# - ProgressBar disappears when changed from within a thread -


The style has been changed within a thread and how can I avoid this happening? P>

I have a thread which runs for an unspecified (but potentially long) time, so I wanted to use the progress bar to track the progress of the thread. Before I started the thread, Marquee I set the progress bar style for, even after the thread is finished, and the progress bar sets the style back to the blocks (which you form. CheckForIlagelCrossBabterCalls = false setting Other threads can disappear from the progress bar. Nature blindly, if I put a button on my form for the purpose of changing the style forward and backward, for the progression of the style, it will appear again, And will change the style back and forth as the button is pressed sequentially.

There! Stay away from CheckForIlagel CrossTradleclass this property, while Microsoft made it available and I'm sure it is very, very, very rare (and I mean rare ) is used for it, it's never Do not touch it will really harm your software.

You can use a simple ISScronioizable approach to update your UI (very easy).

  /// & lt; Summary & gt; The /// Helper class, which allows synchronization to be used in a line of code. /// & lt; / Summary & gt; Inner stable square synchronized invoque {/// & lt; Summary & gt; Invites the specified action on the /// thread that was created on the specified sync object /// & lt; / Summary & gt; Call public static zero (ISynchronizeInvoke sync, verb action) {if (! Sync.InvokeRequired) {action (); } And {object [] args = new object [] {}; Sync.Invoke (action, args); }}}   

The use is easy.

  Private Zero MyThreadWork () {// SynchnronizeInvoke.Invoke (uxProgressBar, () => Ux Progress Bar.Type = Progressbar Style Block); }    

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -