set something on GUI form and thread sleep
<p>I have a GUI window form. I want to set image to pictureBox and next sleep 3 seconds.</p>

<pre><code>   pictureBox.Image = image;
   Thread.Sleep( 3000 );
</code></pre>

<p>But if I do it like my code above, my form try to set image, next go to sleep for 3 seconds, and just after that my form draws itself. So my picture show after this 3 seconds. How can I set image, show it and just after that "go to sleep" ?</p>

<h1>edit 1</h1>

<p>exactly I want to do something like that: </p>

<p>I have two thread, UI and GUI. UI reads from net socket and call right method from GUI. And can be script like that: </p>

<ul>
<li>UI call on GUI: set image </li>
<li>UI call on GUI: do something (then GUI must clear image) </li>
</ul>

<p>But I want to have sure, that I will be able to see this image. So after GUI set image, I call this thread for 3 seconds. So, how can I do it? </p>

<p>Example:
(function from GUI)</p>

<pre><code>public void f1() {
     MethodInvoker method = () =&gt; {
            pictureBox.Image = image;
            pictureBox.Update();
           // do something more
     };

     if ( InvokeRequired ) {
           Invoke( method );
     } else {
           method();
     }

 }

public void f2() {
     MethodInvoker method = () =&gt; {
            pictureBox.Image = null;
            pictureBox.Update();
           // do something more
     };

     if ( InvokeRequired ) {
           Invoke( method );
     } else {
           method();
     }

 }
</code></pre>

<p>And other function f3...fn</p>

<pre><code> public void f3() {
     MethodInvoker method = () =&gt; {
           // do something 
     };

     if ( InvokeRequired ) {
           Invoke( method );
     } else {
           method();
     }

 }
</code></pre>

<p>And, I my UI thread call function f1 and after it f2, I want to be sure that my user will be able to see this picture. But if my UI thread call function f1 and some between f3..fn call it normally.</p>

<h1>edit 2</h1>

<p>No I make it that:
I define function in GUI form (which is called by UI ):</p>

<pre><code>  public void f1() {
         MethodInvoker method = () =&gt; {
                pictureBox.Image = image;
                pictureBox.Update();
         };

         MethodInvoker method2 = () =&gt; {
                // something
         }

        if ( InvokeRequired ) {
                Invoke( method );
                Thread.Sleep( 3000 );  // sleep UI thread
                Invoke( method2 );
        } else {
                method();
                method2();
        }
  }
</code></pre>

<p>It works, but it isn't the best solution. If will be script like this:</p>

<pre><code>- UI call f1
- UI call f3
</code></pre>

<p>UI will be sleep for 3 seconds and I don't expect it.</p>

<p>What is the best solution for my problem?</p>
