Click here to Skip to main content
15,887,776 members
Home / Discussions / C#
   

C#

 
AnswerRe: Fail Uppercase? Pin
BobJanova29-Jul-12 23:03
BobJanova29-Jul-12 23:03 
GeneralRe: Fail Uppercase? Pin
Rob Philpott30-Jul-12 5:31
Rob Philpott30-Jul-12 5:31 
QuestionUsing Thread is not successful Pin
taibc27-Jul-12 16:08
taibc27-Jul-12 16:08 
AnswerRe: Using Thread is not successful Pin
Wes Aday27-Jul-12 16:32
professionalWes Aday27-Jul-12 16:32 
AnswerRe: Using Thread is not successful Pin
Trak4Net27-Jul-12 17:46
Trak4Net27-Jul-12 17:46 
GeneralRe: Using Thread is not successful Pin
taibc27-Jul-12 20:21
taibc27-Jul-12 20:21 
GeneralRe: Using Thread is not successful Pin
taibc6-Aug-12 18:21
taibc6-Aug-12 18:21 
GeneralRe: Using Thread is not successful Pin
Trak4Net13-Aug-12 19:04
Trak4Net13-Aug-12 19:04 
You should read up about making thread-safe calls to controls here is one link http://msdn.microsoft.com/en-us/library/ms171728.aspx[^]

Anytime you access a control from a thread other than the thread the control was created on you will need to use Invoke or BeginInvoke to modify. Usually if there are several common controls I create a method that accepts a control as a parameter as well as the text to set and inside that method it checks if invoke is required.

Here is an example of something you could do. You don't show enough code to know exactly what you are trying but this can be modified to work with different controls etc.

Hope this is helpful.

C#
/// <summary>
/// delegate to invoke when invoke required
/// </summary>
private delegate void ChangeTextDel(System.Windows.Forms.TextBox obj, string newtext);

/// <summary>
/// Changes the text.
/// </summary>
/// <param name="obj">The obj.</param>
/// <param name="newtext">The newtext.</param>
private void ChangeText(System.Windows.Forms.TextBox obj, string newtext)
{
    if (obj.InvokeRequired)
    {
        obj.Invoke(new ChangeTextDel(ChangeText), new object[] { obj, newtext });
    }
    else
    {
        obj.Text = newtext;
    }
}


C#
//from thread
ChangeText(txtLopDiaChi, "my new text value");

GeneralRe: Using Thread is not successful Pin
taibc13-Aug-12 20:44
taibc13-Aug-12 20:44 
Questionhow to set label text here? Pin
Jassim Rahma27-Jul-12 7:36
Jassim Rahma27-Jul-12 7:36 
AnswerRe: how to set label text here? Pin
Ravi Bhavnani27-Jul-12 8:09
professionalRavi Bhavnani27-Jul-12 8:09 
GeneralRe: how to set label text here? Pin
Jassim Rahma27-Jul-12 9:25
Jassim Rahma27-Jul-12 9:25 
AnswerRe: how to set label text here? Pin
Ravi Bhavnani27-Jul-12 9:40
professionalRavi Bhavnani27-Jul-12 9:40 
AnswerRe: how to set label text here? Pin
OriginalGriff27-Jul-12 9:16
mveOriginalGriff27-Jul-12 9:16 
GeneralRe: how to set label text here? Pin
Ravi Bhavnani27-Jul-12 9:41
professionalRavi Bhavnani27-Jul-12 9:41 
GeneralRe: how to set label text here? Pin
OriginalGriff27-Jul-12 9:47
mveOriginalGriff27-Jul-12 9:47 
QuestionTrack two types of values within one variable Pin
hpjchobbes27-Jul-12 4:55
hpjchobbes27-Jul-12 4:55 
AnswerRe: Track two types of values within one variable Pin
SledgeHammer0127-Jul-12 6:28
SledgeHammer0127-Jul-12 6:28 
GeneralRe: Track two types of values within one variable Pin
hpjchobbes27-Jul-12 7:04
hpjchobbes27-Jul-12 7:04 
GeneralMessage Removed Pin
27-Jul-12 6:38
professionalN_tro_P27-Jul-12 6:38 
GeneralRe: Track two types of values within one variable Pin
hpjchobbes27-Jul-12 7:18
hpjchobbes27-Jul-12 7:18 
GeneralRe: Track two types of values within one variable Pin
BillWoodruff29-Jul-12 18:35
professionalBillWoodruff29-Jul-12 18:35 
GeneralRe: Track two types of values within one variable Pin
SledgeHammer0127-Jul-12 11:40
SledgeHammer0127-Jul-12 11:40 
GeneralMessage Removed Pin
27-Jul-12 12:22
professionalN_tro_P27-Jul-12 12:22 
GeneralRe: Track two types of values within one variable Pin
SledgeHammer0127-Jul-12 12:33
SledgeHammer0127-Jul-12 12:33 

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.