473,806 Members | 2,874 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Basic multithreading problem

Hi guys, thanks in advance.

trying to implement some multithreading here :
VS 2003
VB.net winforms
I have a dropdown on a form which has list of vendors, when the user selects
a vendor from this dropdown, a new thread is created which calls a webservice
and the webservice returns the list of cities the vendor is in and this data
is set as the datasource of the city dropdown on the same screen. The thread
takes 4-5 seconds to do all this and all this Works like a charm, by the time
the user some to the city dropdown , it already has the list of cities the
user has selected .

Now what i want to do is when the user selects mutiple values from the
Source dropdown and if there is already a thread created from the user
selection of the previous value (I.e within this 4-5 sec time preriod), i
want to suspend the old thread and then start a new thread which gets the
cities for the new vendor the user has selected and below is the code that i
have. But the problem is when user selects multiple values from the vendor
dropdown in the 4-5 second time period, the thread takes forever, what is
happening here, is it that all the thread that were started at queyed even if
i am suspending it or what how can i stop this from happening, i.e when the
user selects a vendor then i want to suspend any previous thread which was
getting the list of cities for the previous vendor and get the thread started
with the new vaendor selection. Could the problem be due to the webserivce
that the thread creates? please suggest
Waiting for a suggestion.
Below is the code that i am running.

Creating the thread when the user selects a new vendor from the dropdown :

Private function Vendorchanged()
Try
'Checking to suspend any old thread which might still be acttive from
previous selection
If Not thread_refreshc ontact Is Nothing AndAlso
thread_refreshc ontact.IsAlive = True Then

thread_refreshc ontact.Suspend( )

End If

'Beging to re-initialized the thread
thread_refreshc ontact = Nothing
thread_refreshc ontact = New
Threading.Threa d(AddressOf RefreshCity)
thread_refreshc ontact.Name = "vendorcity "
thread_refreshc ontact.IsBackgr ound = True

thread_refreshc ontact.Start()
Catch ex As Exception
MsgBox(ex.ToStr ing)
End Try

End function
'Function being called by the thread above
Private Sub RefreshCity()

Dim custid As Int32 = 0
Dim Dr As DataRow
Dim vendorid As Int32 = 0

Try

DtCity = <CAll the webserivce which returns the datatable with the cities>
Catch ex As Exception

MsgBox(ex.ToStr ing)
End Try

End Sub

Sameer
Aug 18 '06 #1
2 1235
Are you sure you want to get the cities on a different thread..it seems that
that is the critical path execution and you would want to wait until you have
the cities listed in the listbox anyway?
--
Dennis in Houston
"sameer" wrote:
Hi guys, thanks in advance.

trying to implement some multithreading here :
VS 2003
VB.net winforms
I have a dropdown on a form which has list of vendors, when the user selects
a vendor from this dropdown, a new thread is created which calls a webservice
and the webservice returns the list of cities the vendor is in and this data
is set as the datasource of the city dropdown on the same screen. The thread
takes 4-5 seconds to do all this and all this Works like a charm, by the time
the user some to the city dropdown , it already has the list of cities the
user has selected .

Now what i want to do is when the user selects mutiple values from the
Source dropdown and if there is already a thread created from the user
selection of the previous value (I.e within this 4-5 sec time preriod), i
want to suspend the old thread and then start a new thread which gets the
cities for the new vendor the user has selected and below is the code that i
have. But the problem is when user selects multiple values from the vendor
dropdown in the 4-5 second time period, the thread takes forever, what is
happening here, is it that all the thread that were started at queyed even if
i am suspending it or what how can i stop this from happening, i.e when the
user selects a vendor then i want to suspend any previous thread which was
getting the list of cities for the previous vendor and get the thread started
with the new vaendor selection. Could the problem be due to the webserivce
that the thread creates? please suggest
Waiting for a suggestion.
Below is the code that i am running.

Creating the thread when the user selects a new vendor from the dropdown :

Private function Vendorchanged()
Try
'Checking to suspend any old thread which might still be acttive from
previous selection
If Not thread_refreshc ontact Is Nothing AndAlso
thread_refreshc ontact.IsAlive = True Then

thread_refreshc ontact.Suspend( )

End If

'Beging to re-initialized the thread
thread_refreshc ontact = Nothing
thread_refreshc ontact = New
Threading.Threa d(AddressOf RefreshCity)
thread_refreshc ontact.Name = "vendorcity "
thread_refreshc ontact.IsBackgr ound = True

thread_refreshc ontact.Start()
Catch ex As Exception
MsgBox(ex.ToStr ing)
End Try

End function
'Function being called by the thread above
Private Sub RefreshCity()

Dim custid As Int32 = 0
Dim Dr As DataRow
Dim vendorid As Int32 = 0

Try

DtCity = <CAll the webserivce which returns the datatable with the cities>
Catch ex As Exception

MsgBox(ex.ToStr ing)
End Try

End Sub

Sameer
Aug 18 '06 #2
Dennis, thanks for your answer, actually this scenario was the closest to
what i am trying to achive here so i am pretty sure that i want to get the
cities on a different thread.

thanks

"Dennis" wrote:
Are you sure you want to get the cities on a different thread..it seems that
that is the critical path execution and you would want to wait until you have
the cities listed in the listbox anyway?
--
Dennis in Houston
"sameer" wrote:
Hi guys, thanks in advance.

trying to implement some multithreading here :
VS 2003
VB.net winforms
I have a dropdown on a form which has list of vendors, when the user selects
a vendor from this dropdown, a new thread is created which calls a webservice
and the webservice returns the list of cities the vendor is in and this data
is set as the datasource of the city dropdown on the same screen. The thread
takes 4-5 seconds to do all this and all this Works like a charm, by the time
the user some to the city dropdown , it already has the list of cities the
user has selected .

Now what i want to do is when the user selects mutiple values from the
Source dropdown and if there is already a thread created from the user
selection of the previous value (I.e within this 4-5 sec time preriod), i
want to suspend the old thread and then start a new thread which gets the
cities for the new vendor the user has selected and below is the code that i
have. But the problem is when user selects multiple values from the vendor
dropdown in the 4-5 second time period, the thread takes forever, what is
happening here, is it that all the thread that were started at queyed even if
i am suspending it or what how can i stop this from happening, i.e when the
user selects a vendor then i want to suspend any previous thread which was
getting the list of cities for the previous vendor and get the thread started
with the new vaendor selection. Could the problem be due to the webserivce
that the thread creates? please suggest
Waiting for a suggestion.
Below is the code that i am running.

Creating the thread when the user selects a new vendor from the dropdown :

Private function Vendorchanged()
Try
'Checking to suspend any old thread which might still be acttive from
previous selection
If Not thread_refreshc ontact Is Nothing AndAlso
thread_refreshc ontact.IsAlive = True Then

thread_refreshc ontact.Suspend( )

End If

'Beging to re-initialized the thread
thread_refreshc ontact = Nothing
thread_refreshc ontact = New
Threading.Threa d(AddressOf RefreshCity)
thread_refreshc ontact.Name = "vendorcity "
thread_refreshc ontact.IsBackgr ound = True

thread_refreshc ontact.Start()
Catch ex As Exception
MsgBox(ex.ToStr ing)
End Try

End function
'Function being called by the thread above
Private Sub RefreshCity()

Dim custid As Int32 = 0
Dim Dr As DataRow
Dim vendorid As Int32 = 0

Try

DtCity = <CAll the webserivce which returns the datatable with the cities>
Catch ex As Exception

MsgBox(ex.ToStr ing)
End Try

End Sub

Sameer
Aug 21 '06 #3

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

Similar topics

7
1728
by: asfwa | last post by:
I'm new to C++ and I have some basic questions. I have written an app that does some network stuff in a worker thread. The thread function requests something from the server, gets it and creates an object from the server response. Does this thread terminate/stop/die as soon as it completes its last line of code? Or do I have to do something to kill it? I am used to coding Java so I am totally unsure of what I have to do to "clean up"...
11
4275
by: Mark Yudkin | last post by:
The documentation is unclear (at least to me) on the permissibility of accessing DB2 (8.1.5) concurrently on and from Windows 2000 / XP / 2003, with separate transactions scope, from separate threads of a multithreaded program using embedded SQL. Since the threads do not need to share transaction scopes, the sqleAttachToCtx family of APIs do not seem to be necessary. <quote> In the default implementation of threaded applications against...
12
2137
by: Winbatch | last post by:
Hi, I'm trying to learn multithreading and it doesn't seem to be working for me. I have a feeling it has to do with the fact that I'm writing to files rather than to printf, but maybe not. Basically, I wanted to see if it would be faster to write to 4 files at the same time (parallel) rather than 4 in a row (serially). however, when my multithreaded code executes, it seems to do them in order anyway (I expected to see Starting/Ending all...
16
8514
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
6
2317
by: Michael C | last post by:
Hello Can someone please tell me what I'm doing wrong? I'm writing an application that should be using callbacks to perform asynchronous calls to the Win32 API. Problem is it never reaches my callback function. Any feedback is appreciated. Also, any references to websites with examples of .NET async multithreading would be appreciated. Thanks in advance. public serverInfo getSession(string servername) {
2
3743
by: shonend | last post by:
**** sorry about the length of the message. If you can't read the whole thing and still willing to help, read the last 2 paragraphs where the main problem is described. The introduction story is mentioned to, as much clear as possible, give a picture in what environment the problems rise**** Hello experts! I would appreciate if you can address this problem I have and give a hint what could be wrong.
2
3847
by: Multithreading problem in vb.net | last post by:
Greetings, I am new to multithreading and I am trying to implement it in my app. This application is distributed application which needs to refresh every say 5 secs to show some activities in the datagrid. I have implemented querying the database in a separate thread and and then showing it in the datagrid in the UI thread. It all works fine and the datagrid gets updated every 5 secs. This happens in the desktop (Main form) of the...
4
1576
by: Michael | last post by:
Hi, I am trying to create a multithreaded VB 2005 application which attempts to create a new thread per Domain Controller (DC) in my environment. Each thread connects to its allocated DC and enumerates all computer objects and extracts the 'LastLogon' property. The results from each thread is then consolidated so that I can get the true lastlogon date for each computer object. However in my routine thats get actioned per thread, I have...
2
2271
by: Pradnya Patil | last post by:
hi , I am trying to draw ' html div-tag ' on the screen which will resemble a rectangle through vb.net code. I want it to be drawn faster...so I introduced multithreading using Threadpool. I divided the complete drawing into 3 parts..1st will be done by main thread and other two are done in these procedures - <1LongTimeTask <2LongTimeTask2 I have invoked the threads using below method. **************
0
9719
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...
1
10372
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,...
1
7650
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
6877
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
5546
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
5682
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4329
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
3851
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3008
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.