473,799 Members | 3,276 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Queue of Threads

Hi
What I want to do is for using with a PDA, but I think it's a VB.NET
related question, so I ask it here.
It's simple, an user is working with the pda, and from while to while,
has to send data to a server via webservice.
As the process to the webservice can take many seconds, and the user
has to continue working, I thought to send the process in a diferent
thread, and warn the user when it has finished. The problem is that the
user can send other process to the webservice while the first is still
running. What I'm interested is in creating a queue of threads, and
don't let execute the next thread until the previous has finished.
Also I'm not interested in treating this with only SyncLock to prevent
two threads to enter the same time to the process, because I want to
execute the threads in the order I throw them, and I think that with
this only prevention, the threads can execute in the order the computer
determines...
Any idea?

Thanks

Jan 25 '06 #1
3 4488
Jordi,

I like to use the Queue class with threads.

However you need in my opinion only one thread and let that access the queu.
You have than to synclock it, because your background worker is constantly
getting and cleaning the bottom of the queue, while your foreground worker
is filling that at the top (The representation from this text bottom top can
be visa versa what is not important).

http://msdn2.microsoft.com/en-us/lib...ons.queue.aspx

You can use more threads of course, however mostly is the result of that a
less easy to maintanance program while the result in throughput is than
almost nothing or even possible worse.

I hope this gives an idea,

Cor
Jan 25 '06 #2

Jordi Rico wrote:
Hi
What I want to do is for using with a PDA, but I think it's a VB.NET
related question, so I ask it here.
It's simple, an user is working with the pda, and from while to while,
has to send data to a server via webservice.
As the process to the webservice can take many seconds, and the user
has to continue working, I thought to send the process in a diferent
thread, and warn the user when it has finished.


It would probably be easier to use the built-in asynchronous way of
calling webservices - this handles the necessary background threading
for you. There's a topic in the help titled "Accessing an XML Web
Service Asynchronously in Managed Code" which should take you through
how to do this.

--
Larry Lard
Replies to group please

Jan 25 '06 #3
Thanks Cor,
I've implemented a class with a queue and an only thread as you
said,and some flags controling everything, and it works great!

Jan 25 '06 #4

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

Similar topics

4
2779
by: Sachin Jagtap | last post by:
Hi, I am getting exception while poping item from queue, I am writing messages coming from client in a queue in one thread and then in other thread i am reading from queue and writing in file. I have not implemented any syncronization between reading and wrinting, just i checking size of queue, if it is not empty i am reading from queue and wrting to file. somethign like
2
2628
by: Rodrigo García | last post by:
Hi. The problem is a bit hard to explain. I have a ServicedComponent method which runs a distributed transaction consisting on a a MessageQueue reception and several database operations. That ServicedComponent method is called from a pool of threads which get blocked in the Receive method of the queue. At that moment there are as many open transactions in the DTC as the number of threads in the pool. After 60 seconds of inactivity the...
2
2721
by: Hollywood | last post by:
I have a system in which I have a single thread that places data on a Queue. Then I have one worker thread that waits until data is put on the thread and dequeues the Queue and processes that information. Works just fine. However, I possibly need 1..m worker threads that can act on the same piece of data, i.e. when a dequeue happens on the Queue it can't be removed from the Queue until all threads have used it. I've tried to come up...
0
2504
by: Wavemaker | last post by:
One of the things I've struggled with from time to time is handling events raised on different threads. For example, an object could be listening to events from one or more objects running in different threads besides itself. There is a concern for thread safety. There are various ways of dealing with this. One way is to make the class thread safe by putting in locks. But another way is to stream the events from the various threads into a...
6
5001
by: James Radke | last post by:
Hello, I have a multithreaded windows NT service application (vb.net 2003) that I am working on (my first one), which reads a message queue and creates multiple threads to perform the processing for long running reports. When the processing is complete it uses crystal reports to load a template file, populate it, and then export it to a PDF. It works fine so far....
0
1625
by: Dave Coate | last post by:
I am working on a generic way to launch multiple similar processes (threads) at once, but limit the number of threads running at any one time to a number I set. As I understand it the following line makes a Queue "thread safe", so I do not need to explicitly lock and unlock it when multiple threads are working with it. 'Thread safe queue Private IndexQueue As Queue = Queue.Synchronized(New Queue)
4
17344
by: Macca | last post by:
Hi, I've been reading the online documentation for the System.Collections.Queue object on how to implement a threadsafe Queue object. I understand the basics, by using the wrapper returned by Synchronised method, but I'm not sure how to implement it between 2 threads. Has anyone got any suggestions or examples? Thanks
12
1415
by: Paul Rubin | last post by:
I'd like to suggest adding a new operation Queue.finish() This puts a special sentinel object on the queue. The sentinel travels through the queue like any other object, however, when q.get() encounters the sentinel, it raises StopIteration instead of returning the sentinel. It does not remove the sentinel from the queue, so further calls to q.get also raise StopIteration. That permits writing the typical "worker thread" as
19
3400
by: =?ISO-8859-1?Q?Nordl=F6w?= | last post by:
I am currently designing a synchronized queue used to communicate between threads. Is the code given below a good solution? Am I using mutex lock/unlock more than needed? Are there any resources out there on the Internet on how to design *thread-safe* *efficient* data- structures? /Nordlöw
3
5744
by: scriptlearner | last post by:
I am trying to put up a queue (through a logging thread) so that all worker threads can ask it to log messages. However, the problem I am facing is that, well, the logging thread itself is running forever. It does not know when it should exit. Any suggestion? None of the worker threads knows for sure when the logging thread should exit since they don't know what other worker threads are doing. I also try to set a time limit for the...
0
9541
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10251
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
10228
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
10027
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
5463
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
5585
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4141
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
2
3759
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2938
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.