Click here to Skip to main content
15,913,610 members
Home / Discussions / C#
   

C#

 
QuestionRe: How can i add strings to the columns of a dataGridView? [modified]....pls if someone knows.... Pin
TheBeginner7717-Jun-06 13:52
TheBeginner7717-Jun-06 13:52 
QuestionDelegate / Event Behaviour [modified] Pin
Malcolm Smart17-Jun-06 9:55
Malcolm Smart17-Jun-06 9:55 
QuestionRe: Delegate / Event Behaviour Pin
Jun Du17-Jun-06 10:55
Jun Du17-Jun-06 10:55 
AnswerRe: Delegate / Event Behaviour Pin
Malcolm Smart17-Jun-06 11:19
Malcolm Smart17-Jun-06 11:19 
AnswerRe: Delegate / Event Behaviour Pin
Robert Rohde17-Jun-06 11:00
Robert Rohde17-Jun-06 11:00 
GeneralRe: Delegate / Event Behaviour Pin
Malcolm Smart17-Jun-06 11:16
Malcolm Smart17-Jun-06 11:16 
GeneralRe: Delegate / Event Behaviour Pin
Malcolm Smart17-Jun-06 11:59
Malcolm Smart17-Jun-06 11:59 
GeneralRe: Delegate / Event Behaviour Pin
Robert Rohde17-Jun-06 13:29
Robert Rohde17-Jun-06 13:29 
Yes that is what I mean. Its generally unsafe to change GUI elements from another thread than they were created in. Like in your case this will normally not result in an immediate exception but some weird behaviour. This even depends on which OS you are using.
The following snippet will demonstrate how to use Invoke with the standard EventHandler signature:
//in the main form
private void OnEvent(object sender, EventArgs e)
{
    if (base.InvokeRequired) {
        base.Invoke(new EventHandler(OnEvent), 
                    new object[] {sender, e});
    }
    else
    {
        //Do what ever you want to do
    }
}

A bit of explanation:
InvokeRequired just checks if the current thread is the one the form was created in or not. Invoke will then transfer the call over the thread boundaries. Thus this function (when called from a different thread) will call itself again within the correct thread. Note that this call may block if the GUI thread is busy and wait till its free. You could also use BeginInvoke. Then the call would not block while the GUI thread is busy and the thread could keep running. The call would than be made the next time the GUI thread is free.
GeneralRe: Delegate / Event Behaviour Pin
Malcolm Smart17-Jun-06 20:46
Malcolm Smart17-Jun-06 20:46 
AnswerRe: Delegate / Event Behaviour Pin
LongRange.Shooter17-Jun-06 18:15
LongRange.Shooter17-Jun-06 18:15 
GeneralRe: Delegate / Event Behaviour Pin
Malcolm Smart17-Jun-06 20:48
Malcolm Smart17-Jun-06 20:48 
QuestionADO.NET - Inserting a row and getting the ID Pin
AJ12317-Jun-06 9:44
AJ12317-Jun-06 9:44 
AnswerRe: ADO.NET - Inserting a row and getting the ID Pin
LongRange.Shooter17-Jun-06 18:17
LongRange.Shooter17-Jun-06 18:17 
GeneralRe: ADO.NET - Inserting a row and getting the ID Pin
AJ12317-Jun-06 23:08
AJ12317-Jun-06 23:08 
QuestionCreating a Database Connection with C# Pin
v3nn17-Jun-06 9:19
v3nn17-Jun-06 9:19 
AnswerRe: Creating a Database Connection with C# Pin
Guffa17-Jun-06 9:40
Guffa17-Jun-06 9:40 
GeneralRe: Creating a Database Connection with C# [modified] Pin
v3nn17-Jun-06 9:55
v3nn17-Jun-06 9:55 
AnswerRe: Creating a Database Connection with C# Pin
Guffa17-Jun-06 9:59
Guffa17-Jun-06 9:59 
GeneralRe: Creating a Database Connection with C# Pin
v3nn17-Jun-06 11:01
v3nn17-Jun-06 11:01 
GeneralRe: Creating a Database Connection with C# Pin
Guffa17-Jun-06 11:45
Guffa17-Jun-06 11:45 
AnswerRe: Creating a Database Connection with C# Pin
Colin Angus Mackay17-Jun-06 10:02
Colin Angus Mackay17-Jun-06 10:02 
GeneralRe: Creating a Database Connection with C# Pin
v3nn17-Jun-06 10:58
v3nn17-Jun-06 10:58 
QuestionEnter and Tab key Pin
sandi antono17-Jun-06 9:04
sandi antono17-Jun-06 9:04 
AnswerRe: Enter and Tab key Pin
LongRange.Shooter17-Jun-06 18:19
LongRange.Shooter17-Jun-06 18:19 
GeneralRe: Enter and Tab key Pin
sandi antono18-Jun-06 1:29
sandi antono18-Jun-06 1:29 

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.