Click here to Skip to main content
16,008,469 members
Home / Discussions / C#
   

C#

 
QuestionHow to avoid dragging a form Pin
Elvia Gonzalez22-May-06 6:24
Elvia Gonzalez22-May-06 6:24 
QuestionManualResetEvent troubles Pin
Judah Gabriel Himango22-May-06 5:59
sponsorJudah Gabriel Himango22-May-06 5:59 
AnswerRe: ManualResetEvent troubles Pin
leppie22-May-06 6:33
leppie22-May-06 6:33 
GeneralRe: ManualResetEvent troubles Pin
Judah Gabriel Himango22-May-06 7:15
sponsorJudah Gabriel Himango22-May-06 7:15 
GeneralRe: ManualResetEvent troubles Pin
leppie22-May-06 7:34
leppie22-May-06 7:34 
GeneralRe: ManualResetEvent troubles Pin
Judah Gabriel Himango22-May-06 7:38
sponsorJudah Gabriel Himango22-May-06 7:38 
GeneralRe: ManualResetEvent troubles Pin
Judah Gabriel Himango22-May-06 9:21
sponsorJudah Gabriel Himango22-May-06 9:21 
QuestionThreads, Events & BeginInvoke Pin
iswoolley22-May-06 5:11
iswoolley22-May-06 5:11 
I'm having problems getting my head around raising event on the UI thread, and haven't been able to find an example for my particular situation. I've written a homespun class that exposes an integer property, and raises an event whenever it changes:

public class Engine<br />
    {<br />
    public event EventHandler ProgressChanged;<br />
    private int progress;<br />
<br />
    public Engine ()<br />
      {<br />
      progress = 0;<br />
      }<br />
<br />
    public int Progress<br />
      { get { return progress; } }<br />
<br />
    public void Run ()<br />
      {<br />
      for(int index = 0; index < 100; index++)<br />
        {<br />
        Thread.Sleep(1000);<br />
        progress++;<br />
        if(ProgressChanged != null)<br />
          ProgressChanged(this,new EventArgs());<br />
        }<br />
      }<br />
    }


I want to bind this property to a ProgressBar in my UI.

Engine obj = new Engine();<br />
      progressBar.DataBindings.Add("Value",obj,"Progress");<br />
      Thread thread = new Thread(new ThreadStart(obj.Run));<br />
      thread.Start();


But of course I can't update the ProgressBar from my worker thread, that's something I understand and accept. I think I should be using BeginInvoke to raise the event, but I'm lost as to how to do this.

Any ideas? Thanks in advance, Iain. Confused | :confused:
AnswerRe: Threads, Events &amp; BeginInvoke [modified] Pin
Dustin Metzgar22-May-06 6:06
Dustin Metzgar22-May-06 6:06 
GeneralRe: Threads, Events & BeginInvoke [modified] Pin
Iain W22-May-06 9:49
Iain W22-May-06 9:49 
AnswerRe: Threads, Events &amp;amp;amp; BeginInvoke Pin
Judah Gabriel Himango22-May-06 6:13
sponsorJudah Gabriel Himango22-May-06 6:13 
GeneralRe: Threads, Events &amp;amp;amp; BeginInvoke Pin
Iain W22-May-06 9:58
Iain W22-May-06 9:58 
GeneralRe: Threads, Events &amp;amp;amp;amp;amp;amp; BeginInvoke Pin
Judah Gabriel Himango22-May-06 10:16
sponsorJudah Gabriel Himango22-May-06 10:16 
QuestionNeed help Pin
engsrini22-May-06 4:56
engsrini22-May-06 4:56 
AnswerRe: Need help Pin
Judah Gabriel Himango22-May-06 6:16
sponsorJudah Gabriel Himango22-May-06 6:16 
GeneralRe: Need help Pin
engsrini22-May-06 6:37
engsrini22-May-06 6:37 
QuestionType or namespace name could not be found Pin
msolh22-May-06 4:17
msolh22-May-06 4:17 
AnswerRe: Type or namespace name could not be found Pin
User 665822-May-06 5:11
User 665822-May-06 5:11 
GeneralRe: Type or namespace name could not be found Pin
msolh22-May-06 7:57
msolh22-May-06 7:57 
GeneralRe: Type or namespace name could not be found Pin
User 665822-May-06 11:16
User 665822-May-06 11:16 
QuestionDatabinding Listview with array reference Pin
Seraphin22-May-06 3:54
Seraphin22-May-06 3:54 
Questiona question about tabcontrol ? Pin
cmpeng3422-May-06 3:47
cmpeng3422-May-06 3:47 
AnswerRe: a question about tabcontrol ? Pin
KishoreT22-May-06 3:53
KishoreT22-May-06 3:53 
AnswerRe: a question about tabcontrol ? Pin
sathish s22-May-06 4:00
sathish s22-May-06 4:00 
GeneralRe: a question about tabcontrol ? Pin
RaviBattula22-May-06 4:19
professionalRaviBattula22-May-06 4:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.