Event raised on different thread problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Kulgan

    #1

    Event raised on different thread problem

    Hi,

    I have a dataset object that is binded to a datagrid in my main
    thread. Now, when I add a row to the dataset object in a another
    thread (since it may take awhile to complete), sometimes my
    application will crash. I suspect this is because the ListChanged
    event is raised on a different thread to the thread that my dataset
    object was bound to the datagrid. My question is, how do I get around
    this problem? I would think this would be a common problem, but
    haven't found any answers.

    Thanks in advance.
  • John Saunders

    #2
    Re: Event raised on different thread problem

    "Kulgan" <kulganj@yahoo. com.au> wrote in message
    news:3ceb2517.0 411270336.67451 06e@posting.goo gle.com...[color=blue]
    > Hi,
    >
    > I have a dataset object that is binded to a datagrid in my main
    > thread. Now, when I add a row to the dataset object in a another
    > thread (since it may take awhile to complete), sometimes my
    > application will crash. I suspect this is because the ListChanged
    > event is raised on a different thread to the thread that my dataset
    > object was bound to the datagrid. My question is, how do I get around
    > this problem? I would think this would be a common problem, but
    > haven't found any answers.[/color]

    The answer is to add the row on the proper thread. Use dataGrid.Invoke .

    John Saunders


    Comment

    Working...