Results 1 to 3 of 3

Thread: multi-thread programming?

  1. #1
    Constant Bitrate
    Join Date
    Dec 2008
    Posts
    167

    multi-thread programming?

    I want to write a plugin to integrate the pc and car. when plugin load, it read packet from car bus. Such code will be placed in sub New() and runs infiniteloop. Will the RR be blocked? Does I need code with muti-thread?

  2. #2
    Confusion Master
    Auto Apps:loading...
    Enforcer's Avatar
    Join Date
    Sep 2003
    Location
    If you go down to the woods today, You're sure of
    Posts
    14,618
    Plugins when started will take control until they let go, so if you do that then yes.

    What you need to so is initialise your plugin and then enable a timer for that function, that will allow control to pass back to RoadRunner and then when the timer kicks in your plugin can go about it's business.

    bear in mind though you still can't just have an infiniteloop without letting go otherwise you will tie up RoadRunner.

    so really set a timer to poll the packet from the car bus and then let go each time.

  3. #3
    RoadRunner Mastermind
    Auto Apps:loading...
    guino's Avatar
    Join Date
    Nov 2004
    Location
    Toronto, Canada
    Posts
    9,818
    Infinite loops are just "bad practice" in apartment-thread programming (such as vb6). However, a plugin doesn't necessarily have to be an extension plugin, so you could make a completely separate EXE file to integrate with RR, and have your infinite loop in there (with or without threading) and just send/receive data to/from RR when you deem necessary -- this would NOT hang RR unless you called it continuously (without pauses) in your infinite loop.

    If you make an extension plugin that has an infinite loop in it, RR will definitely "hang" waiting for your plugin to return control to it, you can make it work by having RR load your extension plugin, then have your extension plugin create a thread or call a DLL that creates a thread (with your infinite loop in it) -- then RR can continue to execute in parallel with your thread. If you make this extension plugin in VB6, then your safe option is the DLL way. If you make this extension plugin in .NET or some other language, then you can just use the threading support native to the language in question.
    Ride Runner RR's Myspace

    "Being happy is not about having what you want, it's about wanting what you have."
    "The best things in life are always free - but that doesn't mean money can't buy you good things."

Bookmarks

Posting Permissions

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