VB.Net - Multi-Threaded Model Having Problems..

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

    #1

    VB.Net - Multi-Threaded Model Having Problems..

    Salutations!

    New to the forums but have gotten many an idea from lurking over the
    past few months but alas it's time to begin positing; posting to a
    problem I cannot seem to resolve. This is a long description but my
    hopes are the more information the better someone may be able to help
    :)

    The Problem:
    ----------------------------------------------------------------------
    I have an application that, based on configuration, spins a new
    class object into a thread. These threads enable communications to
    specific hardware running on a manufacturing floor.

    Each object, in and of itself, establishes communications to said
    hardware and begins actively monitoring for events, data and
    changes.

    Upon starting the object, inside a new thread spawned by the parent
    thread, I begin my communications and once done perform a .WaitAll()
    call on the `Thread.Current Thread`. This leaves the thread in a
    waitstate allowing the the thread and the object contained within
    persistance as it waits for it's work to be triggered.

    Todate, I have been able to successfully spin these objects and
    persist the threads while waiting and event triggers raised within
    the threaded objects work fine however add another twist; MSMQ.

    Once the parent service, main thread, spins an instance of an
    object class in a new thread occationally the parent receives
    messages via MSMQ wherein the parent needs to instruct the child
    objects (on threads) to perform a task. Calls into these
    objects/threads are proving harder than I had initially anticipated
    and since I cannot seem to get the call to invoke on the target
    threaded objects context I become deadlocked in my communications
    process.

    Quite simply the application logic is:

    Startup:
    --------------
    Service starts, creates new Parent Object
    Parent Object creates new Child Object and adds to internal
    collection
    Parent Object creates new thread for each Child Object and issues
    .Start
    Child Object spins up in own thread establishing communications
    Child Object, utilizing CallBack, notifies Parent of Success and
    .WaitOne
    Parent Object repeats process until all Child Objects created

    Runtime:
    --------------
    Child Object manages it's own thread, processes and methods
    Parent Object receives MSMQ Message for Child Object
    Parent Object calls method inside Child Object to perform task


    The Attempts:
    ----------------------------------------------------------------------
    I have tried various methods to wake the Child thread and issue the
    work via events, callbacks and asynch invokes without success. The
    Child Object is on a STA Thread and upon the Parent Object getting
    the MSMQ Event for a message arrival and the subsequent call to the
    Child, it seems .NET is spinning off a *new* MTA thread with the call
    to the Child Object's method thus deadlocking my communications since
    the Child is already using the same resources.

    I'm tried to implement the ISerializableIn voke, ContextBoundObj ect
    and other `Serializing` avenues in .NET but each and everytime I
    cannot seem to communicate to the Child thread to wake it and perform
    the task given.


    Whew, said this would be long eh? :D

    If anyone could shed light in how to gain the context of the
    threaded Child Object to issues method calls on the thread the Child
    Object resides would be must helpful!

    Additional information can be provided but since encapsulates the
    `general idea` of the problem I'll finish up.

    Thanks in advance

    Richard Berg

Working...