Click here to Skip to main content
   

C#

 
AnswerRe: C# linq issue PinmemberJohn Brett2-Oct-12 7:14 
QuestionHow to store string queries in c# function Pinmembernitin_ion30-Sep-12 18:52 
AnswerRe: How to store string queries in c# function PinprotectorPete O'Hanlon30-Sep-12 20:33 
QuestionC# 2008 update sql server table Pinmemberdcof30-Sep-12 15:19 
QuestionQuartzTypeLib and subtitles Pinmemberaudaijihad30-Sep-12 7:22 
AnswerRe: QuartzTypeLib and subtitles PinmemberRavi Bhavnani30-Sep-12 7:47 
GeneralRe: QuartzTypeLib and subtitles Pinmemberaudaijihad30-Sep-12 12:33 
QuestionUpdating a Label in 2 forms simultaneously PinmemberCSharpNewbie 229-Sep-12 22:37 
Hi,
Here is my question...
I need to design two windows forms applications in such a way that the Form 1 will run for some time and then starts Form 2 in a new thread. Once the Form2 is started I need to update the labels on both the forms simultaneously.

Form1

public Form1()
{
Initialize();
DoSomeOperations();
}

public void DoSomeOperations()
{
updateLabel("Form 1");
Thread.Sleep(10000)
var task1= new Thread (() =>Form2()) {"GUIThread"};
task1.Start();
}

public void Form2()
{
Form2 f2= new Form2();
Application.Run(f2);
}
void updateLabel(string message)
{
label1.text = message; //label in Form1
label1.Refresh();

}

After Form2 is started, I wanted to update the label in Form 1 and Form2 at the same time. That is what ever message I get in Form 1, I need to display it both on Form 1 and Form2. I tried toraise an event in Updatelabel method and assigned the event to a method in the constructor of Form2 but it didnt work. Can somebody please help me with this?

Thanks in advance
AnswerRe: Updating a Label in 2 forms simultaneously PinmemberSmart Arab29-Sep-12 23:40 
AnswerRe: Updating a Label in 2 forms simultaneously PinmvpDave Kreskowiak30-Sep-12 4:01 
GeneralRe: Updating a Label in 2 forms simultaneously PinmemberCSharpNewbie 230-Sep-12 13:20 
AnswerRe: Updating a Label in 2 forms simultaneously PinmemberEmdad_54821-Oct-12 2:44 
QuestionC# check for null in linq [modified] Pinmemberdcof29-Sep-12 10:05 
AnswerRe: C# check for null in linq PinmvpRichard MacCutchan29-Sep-12 22:45 
QuestionEncrypt text file in C# Pinmembergibsray29-Sep-12 8:09 
AnswerRe: Encrypt text file in C# PinmemberSmart Arab29-Sep-12 8:20 
AnswerRe: Encrypt text file in C# PinmemberSandip.Nascar29-Sep-12 9:53 
QuestionPattern for creating class libraries Pinmembernitin_ion28-Sep-12 21:32 
AnswerRe: Pattern for creating class libraries Pinmembern.podbielski28-Sep-12 22:51 
QuestionVisual Studio 10 Naming Issue? PinmemberPDTUM28-Sep-12 10:57 
AnswerRe: Visual Studio 10 Naming Issue? PinmemberEmmanuel Medina Lopez28-Sep-12 12:07 
GeneralRe: Visual Studio 10 Naming Issue? PinmemberPDTUM28-Sep-12 14:31 
AnswerRe: Visual Studio 10 Naming Issue? PinmemberSmart Arab28-Sep-12 23:20 
GeneralRe: Visual Studio 10 Naming Issue? PinmemberPDTUM3-Oct-12 6:25 
GeneralRe: Visual Studio 10 Naming Issue? PinmemberSmart Arab3-Oct-12 8:01 

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

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


Advertise | Privacy | Mobile
Web01 | 2.8.150414.1 | Last Updated 19 Apr 2015
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid