Re: form object



Two observations:

1: any static method should probably be thread-aware; when dealing with
forms, this means that it should probably test currentForm.InvokeRequired
and (if true) push the method onto the owning UI's thread; I'm pretty sure
(not 100%) that Opacity has thread affinity..

2: while(z<10000) {z++;}
I don't mean to be rude - just frank; this is quite possibly the worst way
of putting a delay into code:
* It will run at different speeds on different computers
* it might even get completely removed by an optimizing compiler (typically
only in release mode)
You don't want to Sleep(), as this will hang the UI thread (unless you spin
up a second thread that alternates between Sleep() [on its own thread] and
BeginInvoke() [on the form]); a timer would be the normal implementation?

Marc


.



Relevant Pages

  • Re: Rationale for CS0536?
    ... >> current thread to sleep since Sleep is a static method. ... > design or even naming problem, nothing that would have to be ... Weren't you just asking why the compiler didn't let you call static methods ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Java Code Convention Guidelines question...
    ... The issue is invoking a static method while ... a different thread to sleep. ... confusion, by implying that the method "sleep" acted on a specific other ... about whether a developer should intentionally pretend to act on some ...
    (comp.lang.java.programmer)
  • Re: Help with Thread Sleep Calls causing lack of SLEEP
    ... sleepis a static method. ... Java allows static members to be accessed via references, ... *always* the one which is set to sleep. ... > waiting a random set amount of time for something else to finish - you ...
    (comp.lang.java.help)
  • Re: form object
    ... early on I thought about using a timer since a counter does not run ... concerned about the differing speeds on the various local workstations. ... any static method should probably be thread-aware; ... You don't want to Sleep(), as this will hang the UI thread (unless you spin ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Socket Client , abnormal behavior when sending byte
    ... >>1) Are you using UDP instead of TCP? ... Ooohhh. ... sleep() is a static method that operates on whatever the current thread ...
    (comp.lang.java.programmer)

Loading