Click here to Skip to main content
15,889,931 members
Home / Discussions / C#
   

C#

 
QuestionWindows mobile App with VS2013 C# Pin
Member 1068390225-Nov-14 8:22
Member 1068390225-Nov-14 8:22 
AnswerRe: Windows mobile App with VS2013 C# Pin
Richard MacCutchan25-Nov-14 22:24
mveRichard MacCutchan25-Nov-14 22:24 
GeneralRe: Windows mobile App with VS2013 C# Pin
Member 1068390226-Nov-14 9:58
Member 1068390226-Nov-14 9:58 
QuestionC sharp Pin
Sarita S24-Nov-14 23:50
Sarita S24-Nov-14 23:50 
AnswerRe: C sharp Pin
den2k8825-Nov-14 0:00
professionalden2k8825-Nov-14 0:00 
GeneralRe: C sharp Pin
Sarita S25-Nov-14 0:10
Sarita S25-Nov-14 0:10 
GeneralRe: C sharp Pin
den2k8825-Nov-14 0:24
professionalden2k8825-Nov-14 0:24 
GeneralRe: C sharp Pin
Nicholas Marty25-Nov-14 0:28
professionalNicholas Marty25-Nov-14 0:28 
Accessing controls from another thread than where they where created is prohibited and you need to work around this by using delegates.

Please note that doing something like this is very resource heavy and should be avoided if possible.

Example of how you can do this. If you need to update multiple GUI components make sure you update them all at once as you only need to invoke once.
C#
private void button1_Click(object sender, EventArgs e) {
    Thread th = new Thread(run);
    th.Start();
    run();
}
public void run() {
    for (int i = 0; i < 2; i++) {
        UpdateTextBox("I is now " + i);
        Thread.Sleep(100);
    }
}

private delegate void DUpdateTextBox(string text);
private void UpdateTextBox(string text) {
    if (textBox1.InvokeRequired) {
        var d = new DUpdateTextBox(UpdateTextBox);
        textBox1.Invoke(d, text);
    } else {
        textBox1.Text = text;
    }
}

GeneralRe: C sharp Pin
Sarita S25-Nov-14 0:35
Sarita S25-Nov-14 0:35 
GeneralRe: C sharp Pin
Eddy Vluggen25-Nov-14 0:20
professionalEddy Vluggen25-Nov-14 0:20 
AnswerRe: C sharp Pin
Eddy Vluggen25-Nov-14 0:21
professionalEddy Vluggen25-Nov-14 0:21 
AnswerRe: C sharp Pin
Simon_Whale25-Nov-14 0:23
Simon_Whale25-Nov-14 0:23 
AnswerRe: C sharp Pin
OriginalGriff25-Nov-14 0:24
mveOriginalGriff25-Nov-14 0:24 
AnswerRe: C sharp Pin
Bernhard Hiller25-Nov-14 5:08
Bernhard Hiller25-Nov-14 5:08 
AnswerRe: C sharp Pin
4a616e25-Nov-14 10:11
4a616e25-Nov-14 10:11 
AnswerRe: C sharp Pin
V.27-Nov-14 1:58
professionalV.27-Nov-14 1:58 
QuestionC# - Read App.Config file Pin
Member 1123932724-Nov-14 20:48
Member 1123932724-Nov-14 20:48 
AnswerRe: C# - Read App.Config file Pin
Richard MacCutchan24-Nov-14 21:38
mveRichard MacCutchan24-Nov-14 21:38 
GeneralRe: C# - Read App.Config file Pin
Member 1123932725-Nov-14 22:19
Member 1123932725-Nov-14 22:19 
GeneralRe: C# - Read App.Config file Pin
Richard MacCutchan25-Nov-14 22:54
mveRichard MacCutchan25-Nov-14 22:54 
AnswerRe: C# - Read App.Config file Pin
BillWoodruff25-Nov-14 4:20
professionalBillWoodruff25-Nov-14 4:20 
GeneralC# WPF Move - Rotate - Zoom Image Pin
LamThanhNghia24-Nov-14 13:54
LamThanhNghia24-Nov-14 13:54 
GeneralRe: C# WPF Move - Rotate - Zoom Image Pin
Dave Kreskowiak24-Nov-14 16:52
mveDave Kreskowiak24-Nov-14 16:52 
GeneralRe: C# WPF Move - Rotate - Zoom Image Pin
SledgeHammer0124-Nov-14 17:00
SledgeHammer0124-Nov-14 17:00 
GeneralRe: C# WPF Move - Rotate - Zoom Image Pin
Dave Kreskowiak24-Nov-14 17:07
mveDave Kreskowiak24-Nov-14 17:07 

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.