473,785 Members | 2,321 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

multi threading

hi all, i have a software written in vb.net which has many thread in it.

The software basically use about 8 threads to monitor in coming data
from serial port,

and some other thread that process those data.

What happen is the software will suddenly "dissapear" after running for
some time.

theres no error message or anything, it just end by itself.....

I wondering anyone got this kind of experience before ?

any clue someone ?

I am loosing my hair.... sigh..
Nov 20 '05 #1
15 3050
Alright,

Well, this could be 1 of 1,000,000,000 issues probably. A little vague, but
thats ok. =)

A few questions, especially when your talking about using 8 threads on a
serial port...

1) Why are you using 8 threads to monitor a serial port? You should only
need 1 (depending on what your doing, I really don't see a reason for more,
in fact, I could see problems with this... Especially depending on what your
doing with this data coming from the port. What kind of syncronization are
you using? SyncLock? Muting? Roll your own?

Explain a little more what your doing, and I'll do my best to help you out.
As I've learned from countless people in here, when your using
multi-threading, make sure you have a reason. =)

I think the overall answer you'll be looking for is, 1 thread to monitor and
many to process long functions etc. But the reason its dying *could* be an
unmanaged code issue, I don't know, I have no idea what your code is nor how
your accessing the serial port (API I presume?)

Let me know.

CJ
"aikwee" <ai****@streamy x.com> wrote in message
news:O0******** ******@tk2msftn gp13.phx.gbl...
hi all, i have a software written in vb.net which has many thread in it.

The software basically use about 8 threads to monitor in coming data
from serial port,

and some other thread that process those data.

What happen is the software will suddenly "dissapear" after running for
some time.

theres no error message or anything, it just end by itself.....

I wondering anyone got this kind of experience before ?

any clue someone ?

I am loosing my hair.... sigh..

Nov 20 '05 #2
Hi,

I presume that each thread monitors a separate serial port?

If there are no errors (are you sure you aren't discarding a possible error
by a higher-level error trap), then it will be very hard to find. Offhand,
I don't have any suggestion. These things require hands-on debugging --
we'd just be guessing without having code to examine.

--
Richard Grier (Microsoft Visual Basic MVP)

See www.hardandsoftware.net for contact information.

Author of Visual Basic Programmer's Guide to Serial Communications, 3rd
Edition ISBN 1-890422-27-4 (391 pages) published February 2002.
Nov 20 '05 #3
However... If you are sending data from the threads into an STAThread
process (such as the UI), then you need to marshal the data properly,
otherwise you will experience random failures. You do this by using
Control.Invoke or Control.BeginIn voke.

--
Richard Grier (Microsoft Visual Basic MVP)

See www.hardandsoftware.net for contact information.

Author of Visual Basic Programmer's Guide to Serial Communications, 3rd
Edition ISBN 1-890422-27-4 (391 pages) published February 2002.
Nov 20 '05 #4

"CJ Taylor" <no****@blowgoa ts.com> wrote in message
news:Ob******** ******@TK2MSFTN GP09.phx.gbl...
Alright,

Well, this could be 1 of 1,000,000,000 issues probably. A little vague, but thats ok. =)

A few questions, especially when your talking about using 8 threads on a
serial port...

1) Why are you using 8 threads to monitor a serial port? You should only
need 1 (depending on what your doing, I really don't see a reason for more, in fact, I could see problems with this... Especially depending on what your doing with this data coming from the port. What kind of syncronization are you using? SyncLock? Muting? Roll your own?
the fact is i am monitoring 8 serial ports.
Explain a little more what your doing, and I'll do my best to help you out. As I've learned from countless people in here, when your using
multi-threading, make sure you have a reason. =)

I think the overall answer you'll be looking for is, 1 thread to monitor and many to process long functions etc. But the reason its dying *could* be an unmanaged code issue, I don't know, I have no idea what your code is nor how your accessing the serial port (API I presume?)
i am using the vb.net example for acessing serial port as a model for my
program,...
i see a lot of api calls, is it the root of the problem ?
Let me know.

CJ
"aikwee" <ai****@streamy x.com> wrote in message
news:O0******** ******@tk2msftn gp13.phx.gbl...
hi all, i have a software written in vb.net which has many thread in it.

The software basically use about 8 threads to monitor in coming data
from serial port,

and some other thread that process those data.

What happen is the software will suddenly "dissapear" after running for some time.

theres no error message or anything, it just end by itself.....

I wondering anyone got this kind of experience before ?

any clue someone ?

I am loosing my hair.... sigh..


Nov 20 '05 #5

"Dick Grier" <di************ **@msn.com> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
Hi,

I presume that each thread monitors a separate serial port?
absolutely right....
If there are no errors (are you sure you aren't discarding a possible error by a higher-level error trap), then it will be very hard to find. Offhand, I don't have any suggestion. These things require hands-on debugging --
we'd just be guessing without having code to examine.
oops, i didn't handle all error properly... i presume
try .. catch.. end try = on error resume next

what will happen to unhandled error ?

--
Richard Grier (Microsoft Visual Basic MVP)

See www.hardandsoftware.net for contact information.

Author of Visual Basic Programmer's Guide to Serial Communications, 3rd
Edition ISBN 1-890422-27-4 (391 pages) published February 2002.

Nov 20 '05 #6
hi,

"Dick Grier" <di************ **@msn.com> wrote in message
news:uQ******** ******@TK2MSFTN GP09.phx.gbl...
However... If you are sending data from the threads into an STAThread
process (such as the UI), then you need to marshal the data properly,
otherwise you will experience random failures. You do this by using
Control.Invoke or Control.BeginIn voke.
oh... i did update some UI but for debugging purposes, my porgram suppose to
run headless...
If you are sending data from the threads into an STAThread
process (such as the UI), then you need to marshal the data properly,
this look like alien language to me.... do you have a pointer to a good
reference... ?

--
Richard Grier (Microsoft Visual Basic MVP)

See www.hardandsoftware.net for contact information.

Author of Visual Basic Programmer's Guide to Serial Communications, 3rd
Edition ISBN 1-890422-27-4 (391 pages) published February 2002.

Nov 20 '05 #7
On error resume next doesn't work anymore. Thats the way you use Try Catch
Finally Statements...

Unhandled errors depends on how you catch...

if you catch System.Exceptio n, you'll catch *everything* that could go wrong
(good approach for testing). and then recover.

As far as monitoring 8 different serial ports, are you writing data back to
"primary" thread? Thats why I was asking about your syncronization.

-CJ

-CJ
"aikwee" <ai****@streamy x.com> wrote in message
news:Ou******** ******@tk2msftn gp13.phx.gbl...

"Dick Grier" <di************ **@msn.com> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
Hi,

I presume that each thread monitors a separate serial port?

absolutely right....
If there are no errors (are you sure you aren't discarding a possible

error
by a higher-level error trap), then it will be very hard to find.

Offhand,
I don't have any suggestion. These things require hands-on debugging --
we'd just be guessing without having code to examine.


oops, i didn't handle all error properly... i presume
try .. catch.. end try = on error resume next

what will happen to unhandled error ?

--
Richard Grier (Microsoft Visual Basic MVP)

See www.hardandsoftware.net for contact information.

Author of Visual Basic Programmer's Guide to Serial Communications, 3rd
Edition ISBN 1-890422-27-4 (391 pages) published February 2002.


Nov 20 '05 #8
thanks for repling..
On error resume next doesn't work anymore. Thats the way you use Try Catch Finally Statements... Unhandled errors depends on how you catch...

if you catch System.Exceptio n, you'll catch *everything* that could go wrong (good approach for testing). and then recover.
i do :
Try
....some codes here
catch ex as exception
`doesn't do anything here
end try

in a thread so that it will recover and run on and on again....
is it right ?
As far as monitoring 8 different serial ports, are you writing data back to "primary" thread? Thats why I was asking about your syncronization.
i presume what you mean by "primary thread" is the thread that start the 8
threads....

no , 8 serial ports threads don't write back to main thread, the just put
the data in a class
for other processes to read (only)
"CJ Taylor" <no****@blowgoa ts.com> wrote in message
news:%2******** ********@TK2MSF TNGP11.phx.gbl. .. On error resume next doesn't work anymore. Thats the way you use Try Catch Finally Statements...

Unhandled errors depends on how you catch...

if you catch System.Exceptio n, you'll catch *everything* that could go wrong (good approach for testing). and then recover.

As far as monitoring 8 different serial ports, are you writing data back to "primary" thread? Thats why I was asking about your syncronization.

-CJ

-CJ
"aikwee" <ai****@streamy x.com> wrote in message
news:Ou******** ******@tk2msftn gp13.phx.gbl...

"Dick Grier" <di************ **@msn.com> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
Hi,

I presume that each thread monitors a separate serial port?

absolutely right....
If there are no errors (are you sure you aren't discarding a possible

error
by a higher-level error trap), then it will be very hard to find.

Offhand,
I don't have any suggestion. These things require hands-on debugging -- we'd just be guessing without having code to examine.


oops, i didn't handle all error properly... i presume
try .. catch.. end try = on error resume next

what will happen to unhandled error ?

--
Richard Grier (Microsoft Visual Basic MVP)

See www.hardandsoftware.net for contact information.

Author of Visual Basic Programmer's Guide to Serial Communications, 3rd Edition ISBN 1-890422-27-4 (391 pages) published February 2002.



Nov 20 '05 #9

"aikwee" <ai****@streamy x.com> wrote in message
news:eI******** ******@TK2MSFTN GP11.phx.gbl...
thanks for repling..
not a problem
On error resume next doesn't work anymore. Thats the way you use Try

Catch
Finally Statements...

Unhandled errors depends on how you catch...

if you catch System.Exceptio n, you'll catch *everything* that could go

wrong
(good approach for testing). and then recover.


i do :
Try
...some codes here
catch ex as exception
`doesn't do anything here
end try

in a thread so that it will recover and run on and on again....
is it right ?


Right.
As far as monitoring 8 different serial ports, are you writing data back

to
"primary" thread? Thats why I was asking about your syncronization.


i presume what you mean by "primary thread" is the thread that start the

8 threads....

Yeah. exactly.
no , 8 serial ports threads don't write back to main thread, the just put
the data in a class
for other processes to read (only)
Thats where you might want to use some SyncLocking of some kind. Deny
another thread the rights to read or write from here becaues you could have
some data issues.. Maybe, maybe not, I'm just anal that way and like to
have it that way. You still have communication between 2 threads through
this class (whether it goes directly back to the primary thread or not) in
which case you can still get some errors or inaccurate data.
"CJ Taylor" <no****@blowgoa ts.com> wrote in message
news:%2******** ********@TK2MSF TNGP11.phx.gbl. ..
On error resume next doesn't work anymore. Thats the way you use Try

Catch
Finally Statements...

Unhandled errors depends on how you catch...

if you catch System.Exceptio n, you'll catch *everything* that could go

wrong
(good approach for testing). and then recover.

As far as monitoring 8 different serial ports, are you writing data back

to
"primary" thread? Thats why I was asking about your syncronization.

-CJ

-CJ
"aikwee" <ai****@streamy x.com> wrote in message
news:Ou******** ******@tk2msftn gp13.phx.gbl...

"Dick Grier" <di************ **@msn.com> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
> Hi,
>
> I presume that each thread monitors a separate serial port?
>
absolutely right....

> If there are no errors (are you sure you aren't discarding a possible error
> by a higher-level error trap), then it will be very hard to find.
Offhand,
> I don't have any suggestion. These things require hands-on debugging -- > we'd just be guessing without having code to examine.

oops, i didn't handle all error properly... i presume
try .. catch.. end try = on error resume next

what will happen to unhandled error ?

>
> --
> Richard Grier (Microsoft Visual Basic MVP)
>
> See www.hardandsoftware.net for contact information.
>
> Author of Visual Basic Programmer's Guide to Serial Communications, 3rd > Edition ISBN 1-890422-27-4 (391 pages) published February 2002.
>
>



Nov 20 '05 #10

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

Similar topics

37
4899
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, Pujo
77
5390
by: Jon Skeet [C# MVP] | last post by:
Please excuse the cross-post - I'm pretty sure I've had interest in the article on all the groups this is posted to. I've finally managed to finish my article on multi-threading - at least for the moment. I'd be *very* grateful if people with any interest in multi-threading would read it (even just bits of it - it's somewhat long to go through the whole thing!) to check for accuracy, effectiveness of examples, etc. Feel free to mail...
0
1814
by: Stuart Norris | last post by:
Dear Group, I am attempting to write a "splash" and "status" Form using a second thread. I wish to use this Form to display status information to the user when I do CPU intensive work in my GUI during startup. I wish to also use the same Form after startup as well if I do something CPU intensive. I have developed a multi-threaded application however the very first
13
348
by: notregister | last post by:
my program have as many as 8 threads running at a same time. can different threads open a same file at the same time? let say thread1 open a file abc.txt at the same time with thread 2, both doing at different operation...
2
4891
by: NiponW | last post by:
Hi, I have SQL SERVER 2000 SP4 Enterprise , Windows 2003 Enterprise on Xeon 4 Processors (now with multi-threading CPU) and I have questions which seem weirds to me (used to have the same config without Multi-Threading) as following: 1. SQL Server see 8 CPUs. Is this because of multi-threading CPUs ? 2. when use SP_WHO2 ACTIVE ,
20
5968
by: dotyet | last post by:
Hi Everyone, It would be a real big help if anyone can shed light on whether DB2 UDB 8.2 on Solaris will make optimum use of a Sun T2000 server. The server has 1 CPU with 8 cores and each core has 4 threads (32 virtual CPUs). We are exploring this option againts an equivalent performance pSeries box. But before we delve deeper, we want some basic info on that. Any suggestions would be helpful.
0
1879
ammoos
by: ammoos | last post by:
hi friends pls help me.. i got an assignment which i feel very difficult to me.. i dont have more knowledge about multi-threading in .net... the assignment details is below.... pls help me... i have to submit this assignment today evening... please....... Windows Application to demonstrate the use of Multi-Threading with Synchronous & Asynchronous Threading. Requirements 1) A form with a) a button to initialize threads ...
14
3459
by: Akihiro KAYAMA | last post by:
Hi all. I found cooperative multi-threading(only one thread runs at once, explicit thread switching) is useful for writing some simulators. With it, I'm able to be free from annoying mutual exclusion, and make results deterministic. For this purpose, and inspired by Ruby(1.9) fiber, I wrote my own version of fiber in Python.
5
3524
by: George Maicovschi | last post by:
As multi-threading is not built in PHP I've been using a hack letting the Apache server handle the multi-threading issues, but I'm really curious of other approaches to this issue. If anyone has any ideas I'd be more than glad to hear them up and discuss them.
1
1711
by: =?Utf-8?B?QU1lcmNlcg==?= | last post by:
Sorry this is so long winded, but here goes. Following the model of http://msdn2.microsoft.com/en-us/library/system.runtime.remoting.channels.ipc.ipcchannel.aspx I made a remote object using the IpcChannel Class (vs 2005, vb, fw 2.0). Everyting works fine. The object is registered with WellKnownObjectMode.Singleton The remote object appears at the bottom of this posting. The code is deliberately obtuse to expose an issue about when...
0
10356
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10100
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9959
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8988
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6744
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5396
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5528
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4061
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2893
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.