473,408 Members | 1,852 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,408 software developers and data experts.

Threading using QueueUserWorkItem

Hi,

Iam working in windows appln using .NET framework 2.0.
My application is having several threads running.
All threads can call a common method.
I have following code in my common method.
Threading.ThreadPool.QueueUserWorkItem(New Threading.WaitCallback(

_
AddressOf MyFunction))
When I call the common method, its executing "MyFunction" twice.
I want the "MyFunction" to execute only once.
Any suggestions please.
Regards,
Bharathi Kumar

Sep 14 '06 #1
3 1347
Bharathi,

That's certainly not what's suppose to happen. I think you'll have to
provide a short, but complete program that demonstrates the problem.

Brian

Bharathi kumar wrote:
Hi,

Iam working in windows appln using .NET framework 2.0.
My application is having several threads running.
All threads can call a common method.
I have following code in my common method.
Threading.ThreadPool.QueueUserWorkItem(New Threading.WaitCallback(

_
AddressOf MyFunction))
When I call the common method, its executing "MyFunction" twice.
I want the "MyFunction" to execute only once.
Any suggestions please.
Regards,
Bharathi Kumar
Sep 14 '06 #2
Hi,

Iam sorry. Its working fine.

One of my colleague had modified the code. They have added one more
thread thats calling "MyFunction".

So "MyFunction" had called twice.

I didn't notice that code and thought the behaviour was peculiar.

Thank you very much,
Regards,
Bharathi Kumar.
Brian Gideon wrote:
Bharathi,

That's certainly not what's suppose to happen. I think you'll have to
provide a short, but complete program that demonstrates the problem.

Brian

Bharathi kumar wrote:
Hi,

Iam working in windows appln using .NET framework 2.0.
My application is having several threads running.
All threads can call a common method.
I have following code in my common method.
Threading.ThreadPool.QueueUserWorkItem(New Threading.WaitCallback(

_
AddressOf MyFunction))
When I call the common method, its executing "MyFunction" twice.
I want the "MyFunction" to execute only once.
Any suggestions please.
Regards,
Bharathi Kumar
Sep 15 '06 #3
Bharathi,

I'm glad you figured it out.

Brian

Bharathi kumar wrote:
Hi,

Iam sorry. Its working fine.

One of my colleague had modified the code. They have added one more
thread thats calling "MyFunction".

So "MyFunction" had called twice.

I didn't notice that code and thought the behaviour was peculiar.

Thank you very much,
Regards,
Bharathi Kumar.
Sep 15 '06 #4

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

Similar topics

5
by: OpticTygre | last post by:
Heheh...I've got lots of questions today. If I have a loop that calls the same subroutine several times (that subroutine may be processor and network intensive): For i = 1 to 100 Call...
0
by: Colmeister | last post by:
I recently read Jason Clark's excellent article on Unhandled Exceptions (http://msdn.microsoft.com/msdnmag/issues/04/06/NET/default.aspx) and have attempted to incorporate the features he talks...
3
by: Jayme Pechan | last post by:
I was wondering if someone could help me understand why it seems that creating threads using the code below causes handles to seemingly leak. System.Threading.Thread threadRunAsync = new...
6
by: venkat | last post by:
Hi, I have a page that calls a sql procedure and it runs for 20 - 40 min. I use usual threading for this page. <code>Thread objthread = new Thread(new ThreadStart(ticketingThread));...
4
by: Bharathi | last post by:
Hi, Iam working in windows appln using .NET framework 2.0. My application is having several threads running. All threads can call a common method.
4
by: DBC User | last post by:
I have a background process which reads a table to see if there are any pending requests. If there are any, then it will start a worker thread (only 10 allowed at a time) and executes a method. In...
3
by: Richard MSL | last post by:
I have a C# application that works, with a main menu where the user can choose different options that run, and then return to the menu. I want to change it so that the user can starting running an...
7
by: Mike P | last post by:
I am trying to write my first program using threading..basically I am moving messages from an Outlook inbox and want to show the user where the process is up to without having to wait until it has...
2
by: Mike P | last post by:
I am using the following code, what I need to know is, what do I do if I want to pass parameters to DoSomeWork? I don't understand how the callback variable is passed to DoSomeWork. private...
19
by: frankiespark | last post by:
Hello all, I was perusing the internet for information on threading when I came across this group. Since there seems to be a lot of good ideas and useful info I thought I'd pose a question. ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
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.