|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Queue of ThreadsWhat 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 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/library/system.collections.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 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! Jordi Rico wrote:
> Hi It would probably be easier to use the built-in asynchronous way of> 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. 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
Show Modal, then Again
TopMost without SetFocus throw/handle exceptions while using backgroundworker DUMB question about IndexOf What is the correct case convention for Set? Listbox idiotic example progress bar right to left Importing XML File into an Empty Access Table How to use a Generic's base type? deleting files greater than x days |
|||||||||||||||||||||||