Results 1 to 3 of 3

Thread: [2.0] Threads sharing a variable

  1. #1

    Thread Starter
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051

    [2.0] Threads sharing a variable

    I've got 2 threads, one deals with the UI the other adds stuff to a Queue variable. I want to get the UI thread to do stuff whenever the other thread adds to the queue.

    I've searched and searched, but i'm not sure what i can do. I think in .NET 1.0/1.1 there was a CallBack variable which could be used to call a method in another thread, but it seems to have gone in 2.0
    I've looked into raising an even in the UI thread, but i'm just not sure quite how to do it.

    Any help or simple example would be greatly appreciated!
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2.0] Threads sharing a variable

    You would define a method that raises your event and then you would invoke it from the other thread using a delegate. A forum search should turn up examples of doing so. if not, check out the help topic for the Control.Invoke method.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051

    Resolved [RESOLVED] Re: [2.0] Threads sharing a variable

    Thanks for your help, i managed to find a few relevent threads, knowing what i was looking for.
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width