473,657 Members | 2,458 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help on Multithreading

Hi,

I have an application that runs a timer and executes a method in a class as
a new thread every 60 seconds, the thread takes 65 seconds to execute so
there is a 5 second overlap when 2 threads are running.

The problem i have is that i am experiencing sudden high CPU utilization
that lasts for a couple of seconds, and i believe that i have managed to tie
this down to occuring when the thread is terminated.

If I in the end of the thread use

threading.threa d.currentthread .abort
threading.threa d.currentthread .join

as the documentation specifies is the correct way of terminating a thread, i
get a 3-4 second 100% CPU spike that my application can't live with

If I don't use any code at all in the end of the method or only specifies
threading.threa d.currentthread .join, everything runs smooth for about 25
minutes and then no more threads are executed and if i monitor the .Net CLR
Locking & Threads-> # Current recogized threads i can see that this value
increases until it reaches 25 which i believe is the default maximum number
of threads the CLR accepts.

Question is:

What am i doing wrong ? Am i supposed to actively abort my threads and if so
why do i get this CPU spike ? Are there any other ways of ending a thread ?
Why is the number of threads increasing, is there a way to "reclaim" threads
that has finished

Appreciate all help on this

Regards

Niclas
Nov 20 '05 #1
5 2319
Thanks Fergus,

I have some more info, and i am now not sure if this is a multithreading
issue any more....

When the thread runs out, i raise a event that the processing has completed
that has a handler in the originating for that does some processing. This
processing consists in sending a byte array to a server through a remoting
component.

If i comment out the sending of the byte array, the threads runs smoothly
and they seem to finish properly without any aborts and the number of
threads are not increasing.

The remoting component method works brilliant under all circumstances except
for when a thread aborts. If i set therad.sleep(th read.timeout.in definately)
for examle everything works like a charm untill all connections has been
used up. I have also thried to sleep the thread for a couple of minutes to
make sure that all file processing is done (which takes less than a second)
before i allow the thread to terminate, but this only delays the high CPU
problem with the same time as i sleep the thread.

Are there any known issues with remoting and multithreading that you are
aware of ?

Thanks

for helping out

Niclas

"Fergus Cooney" <wo****@tesco.n et> wrote in message
news:e4******** ******@TK2MSFTN GP09.phx.gbl...
Hi Niclas,

Sorry about that. :-) We've just about finished a monster marathon
post-thread on multi-threading!!.

Some questions.

1) Have you tried running your thread for, say, 50 seconds and
then killing it ?
This will tell you whether it is the killing or the overlap of
the two threads that is suspect.

2) Are these ThreadPool threads or are the fresh Threads each
time. Have you tried the ThreadPool to see if it makes any difference
?

3) Do you have to kill your Thread or can you have you have it
sleep before tasking on the next task?

4) If none of the above give you useful information, can you post
some code to play with?

Regards
Fergus

Nov 20 '05 #2
Lol, Chris,

Spoke too soon, cos Nick came online and Multithreading in VB.NET
has to be the best chat room going.

Regards,
Fergus
Nov 20 '05 #3
Hi again Niclas,

I'm afraid I've not done any remoting.

Have you explored 2) and 3) and considered 4) from my previous
post?

For 4) I'd want something minimal that's quick to download and
will compile without needing too much, if any, of your app stuff. If
you do send it, use my email.

Another question, too:
You say that you raise an event which then does the remote call.
Which thread is that executed in ?

Awaiting your experimentation .

Regards
Fergus
Nov 20 '05 #4
Fergus,

I just found that my CPU spike was caused by a Do-While loop and not related
to multithreading. Guess i got mislead by all the fancy stuff and had the
solution staring at me all time.

Sorry for wasting your time on this

Thanks for trying to help

Regards

Niclas
"Fergus Cooney" <wo****@tesco.n et> wrote in message
news:O0******** ******@TK2MSFTN GP12.phx.gbl...
Hi again Niclas,

I'm afraid I've not done any remoting.

Have you explored 2) and 3) and considered 4) from my previous
post?

For 4) I'd want something minimal that's quick to download and
will compile without needing too much, if any, of your app stuff. If
you do send it, use my email.

Another question, too:
You say that you raise an event which then does the remote call.
Which thread is that executed in ?

Awaiting your experimentation .

Regards
Fergus

Nov 20 '05 #5
Lol. No worries Niclas.

Blinded by the light,
I looked up,
I looked back.
Now everything's all right

Best wishes,
Fergus
Nov 20 '05 #6

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

Similar topics

47
3722
by: mihai | last post by:
What does the standard say about those two? Is any assurance that the use of STL is thread safe? Have a nice day, Mihai.
16
8493
by: Robert Zurer | last post by:
Can anyone suggest the best book or part of a book on this subject. I'm looking for an in-depth treatment with examples in C# TIA Robert Zurer robert@zurer.com
9
13608
by: Popoxinhxan | last post by:
Dear experts, i want to develop an client application that consume the google search web service. In my MainForm i have a method to retrieve all the search result e.g. GetGoogleResults(). Now i want to have a nice progress bar in another form e.g ProgressForm to perform the search action. i tried to do it but the progress bar won't work and the GUI freezed. I knew how to do with the single threading but i don't know how to do it in...
5
2133
by: sarge | last post by:
I would like to know how to perform simple multithreading. I had created a simple form to test out if I was multithreading properly, but got buggy results. Sometime the whole thig would lock up when I got two threads going at the same time. What I have is two text boxes (textBox1 and textBox2) and four buttons(cmdStartThread1, cmdStartThread2, cmdStopThread1, cmdStopThread2)
9
2455
by: tommy | last post by:
hi, i have found a example for multithreading and asp.net http://www.fawcette.com/vsm/2002_11/magazine/features/chester/ i want to speed up my website ... if my website is starting, they should build a database-connection and send a few sqls
2
2307
by: Rich | last post by:
Hello, I have set up a multithreading routine in a Test VB.net proj, and it appears to be working OK in debug mode and I am not using synchronization. Multithreading is a new thing for me, and I just wanted to ask if I am missing anything based on the following scenario. My test app pulls data from a large external data source which has a table-like structure (but not rdbms - more
55
3299
by: Sam | last post by:
Hi, I have a serious issue using multithreading. A sample application showing my issue can be downloaded here: http://graphicsxp.free.fr/WindowsApplication11.zip The problem is that I need to call operations on Controls from a delegate, otherwise it does not work. However each time I've done an operation, I must update the progressbar and progresslabel, but this cannot be done in the delegate as it does not work.
5
2483
by: sandy82 | last post by:
Whats actuallly multithreading is ... and how threading and multithreading differ . Can any1 guide how multithreading is used on the Web .. i mean a practical scenario in which u use multithreading online using C# .
7
16301
by: Ray | last post by:
Hello, Greetings! I'm looking for a solid C++ multithreading book. Can you recommend one? I don't think I've seen a multithreading C++ book that everybody thinks is good (like Effective C++ or Exceptional C++, for example). Platform-specific (e.g.: Win32, POSIX) is OK, as long as it's good :) Thank you, Ray
0
8421
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8742
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8518
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
8621
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
7354
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...
1
6177
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5643
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
4173
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
4330
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.