473,396 Members | 2,029 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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.CurrentThread`. 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 ISerializableInvoke, ContextBoundObject
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

Nov 21 '05 #1
1 1642

"BergRD" <ri**********@delphi-dot-com.no-spam.invalid> wrote in message
news:41**********@Usenet.com...
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.CurrentThread`. 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.


Here's a class I wrote that might help.

http://groups.google.com/groups?hl=e...TNGP10.phx.gbl

You would create a new SingleThreadWorkQueue using a delegate pointing to
the business end of your child object. Then from the main thread just use
the SingleThreadWorkQueue.AddWork method. It will wake up the worker thread
(if it is idle) and queue the work if not.

David
Nov 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

37
by: ajikoe | last post by:
Hello, Is anyone has experiance in running python code to run multi thread parallel in multi processor. Is it possible ? Can python manage which cpu shoud do every thread? Sincerely Yours,...
4
by: Frank Jona | last post by:
Intellisense with C# and a multi-file assembly is not working. With VB.NET it is working. Is there a fix availible? We're using VisualStudio 2003 Regards Frank
12
by: * ProteanThread * | last post by:
but depends upon the clique: ...
0
by: frankenberry | last post by:
I have multi-page tiff files. I need to extract individual frames from the multi-page tiffs and save them as single-page tiffs. 95% of the time I receive multi-page tiffs containing 1 or more black...
6
by: Joe | last post by:
I have 2 multi-list boxes, 1 displays course categories based on a table called CATEGORIES. This table has 2 fields CATEGORY_ID, CATEGORY_NAME The other multi-list box displays courses based on...
4
by: mimmo | last post by:
Hi! I should convert the accented letters of a string in the correspondent letters not accented. But when I compile with -Wall it give me: warning: multi-character character constant Do the...
5
by: Shane Story | last post by:
I can seem to get the dimensions of a frame in a multiframe tiff. After selecting activeframe, the Width/Height is still really much larger than the page's actual dimensions. When I split a...
5
by: bobwansink | last post by:
Hi, I'm relatively new to programming and I would like to create a C++ multi user program. It's for a project for school. This means I will have to write a paper about the theory too. Does anyone...
5
by: dkelly925 | last post by:
Is there a way to add an If Statement to the following code so if data in a field equals "x" it will launch one report and if it equals "y" it would open another report. Anyone know how to modify...
1
by: mknoll217 | last post by:
I am recieving this error from my code: The multi-part identifier "PAR.UniqueID" could not be bound. The multi-part identifier "Salary.UniqueID" could not be bound. The multi-part identifier...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.