Click here to Skip to main content
15,920,603 members
Home / Discussions / C#
   

C#

 
AnswerRe: The best algorithm to get information (class, methos, enum, ...) in C# project Pin
PIEBALDconsult4-Oct-10 2:54
mvePIEBALDconsult4-Oct-10 2:54 
GeneralRe: The best algorithm to get information (class, methos, enum, ...) in C# project Pin
ndkit4-Oct-10 16:33
ndkit4-Oct-10 16:33 
QuestionCompiler in C# Pin
Anubhava Dimri3-Oct-10 18:23
Anubhava Dimri3-Oct-10 18:23 
AnswerRe: Compiler in C# Pin
Luc Pattyn3-Oct-10 18:41
sitebuilderLuc Pattyn3-Oct-10 18:41 
GeneralRe: Compiler in C# Pin
Anubhava Dimri3-Oct-10 20:05
Anubhava Dimri3-Oct-10 20:05 
GeneralRe: Compiler in C# Pin
Vimalsoft(Pty) Ltd3-Oct-10 21:35
professionalVimalsoft(Pty) Ltd3-Oct-10 21:35 
GeneralRe: Compiler in C# Pin
harold aptroot4-Oct-10 1:00
harold aptroot4-Oct-10 1:00 
QuestionHow to access multiple controls thread safe in Windows Forms Pin
poda3-Oct-10 17:28
poda3-Oct-10 17:28 
Many examples explains thread safe access over a single control,like updating a text of a
button or label etc.,How to change properties of multiple controls of a Form in thread safe manner.
private Thread CheckStatusThread = null;
public delegate void CheckStatusDelegate(int Count);
public CheckStatusDelegate CheckStatusHandler;

public Form1()
{
   InitializeComponent();
   CheckStatusThread = new Thread(new ThreadStart(CheckStatusThreadFunc));
   CheckStatusHandler = new CheckStatusDelegate(CheckPowerStatus);
}
private void Form1_Load(object sender, EventArgs e)
{
   CheckStatusThread.Start();
}   
public void CheckStatusThreadFunc()
{            
   int Cnt = 1;
   while (true)
   {
      this.Invoke(CheckStatusHandler,new object []{Cnt});//executed in Form1's own thread(?)
      Cnt++;
      Thread.Sleep(500);
   }
}

public void CheckPowerStatus(int Count)
{
   int Cnt=Count;            
                            
   //Update 3 controls properties
   StatusBarLabel1.Text = "Checking PowerStatus " + Cnt;                 
   dataGridView1.Rows[2].Cells[4].Value = Cnt;
   label1.Text = Convert.ToString("Cnt "+Cnt);                  
}

The CheckPowerStatus function change properties of 3 controls in Form1.
Do I need to use 3 delegates to update each control on 3 different functions.
Or the above code is thread safe?
AnswerRe: How to access multiple controls thread safe in Windows Forms Pin
Mycroft Holmes3-Oct-10 17:45
professionalMycroft Holmes3-Oct-10 17:45 
GeneralRe: How to access multiple controls thread safe in Windows Forms Pin
Luc Pattyn3-Oct-10 17:49
sitebuilderLuc Pattyn3-Oct-10 17:49 
AnswerRe: How to access multiple controls thread safe in Windows Forms Pin
Luc Pattyn3-Oct-10 17:48
sitebuilderLuc Pattyn3-Oct-10 17:48 
GeneralRe: How to access multiple controls thread safe in Windows Forms Pin
poda3-Oct-10 21:08
poda3-Oct-10 21:08 
GeneralRe: How to access multiple controls thread safe in Windows Forms Pin
Luc Pattyn4-Oct-10 1:32
sitebuilderLuc Pattyn4-Oct-10 1:32 
GeneralRe: How to access multiple controls thread safe in Windows Forms Pin
poda4-Oct-10 5:40
poda4-Oct-10 5:40 
GeneralRe: How to access multiple controls thread safe in Windows Forms Pin
Luc Pattyn4-Oct-10 5:55
sitebuilderLuc Pattyn4-Oct-10 5:55 
GeneralRe: How to access multiple controls thread safe in Windows Forms Pin
#realJSOP4-Oct-10 2:03
professional#realJSOP4-Oct-10 2:03 
GeneralRe: How to access multiple controls thread safe in Windows Forms Pin
poda4-Oct-10 5:42
poda4-Oct-10 5:42 
QuestionMessage Filter Pin
electriac3-Oct-10 11:37
electriac3-Oct-10 11:37 
AnswerRe: Message Filter Pin
Henry Minute3-Oct-10 11:49
Henry Minute3-Oct-10 11:49 
AnswerRe: Message Filter Pin
Dave Kreskowiak3-Oct-10 11:58
mveDave Kreskowiak3-Oct-10 11:58 
GeneralRe: Message Filter Pin
electriac3-Oct-10 12:03
electriac3-Oct-10 12:03 
AnswerRe: Message Filter Pin
Luc Pattyn3-Oct-10 12:03
sitebuilderLuc Pattyn3-Oct-10 12:03 
QuestionYield break Pin
Brij3-Oct-10 8:12
mentorBrij3-Oct-10 8:12 
AnswerRe: Yield break Pin
harold aptroot3-Oct-10 8:48
harold aptroot3-Oct-10 8:48 
AnswerRe: Yield break Pin
Henry Minute3-Oct-10 8:56
Henry Minute3-Oct-10 8:56 

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.