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

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_refreshcontact Is Nothing AndAlso
thread_refreshcontact.IsAlive = True Then

thread_refreshcontact.Suspend()

End If

'Beging to re-initialized the thread
thread_refreshcontact = Nothing
thread_refreshcontact = New
Threading.Thread(AddressOf RefreshCity)
thread_refreshcontact.Name = "vendorcity"
thread_refreshcontact.IsBackground = True

thread_refreshcontact.Start()
Catch ex As Exception
MsgBox(ex.ToString)
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.ToString)
End Try

End Sub

Sameer
Aug 18 '06 #1
2 1208
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_refreshcontact Is Nothing AndAlso
thread_refreshcontact.IsAlive = True Then

thread_refreshcontact.Suspend()

End If

'Beging to re-initialized the thread
thread_refreshcontact = Nothing
thread_refreshcontact = New
Threading.Thread(AddressOf RefreshCity)
thread_refreshcontact.Name = "vendorcity"
thread_refreshcontact.IsBackground = True

thread_refreshcontact.Start()
Catch ex As Exception
MsgBox(ex.ToString)
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.ToString)
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_refreshcontact Is Nothing AndAlso
thread_refreshcontact.IsAlive = True Then

thread_refreshcontact.Suspend()

End If

'Beging to re-initialized the thread
thread_refreshcontact = Nothing
thread_refreshcontact = New
Threading.Thread(AddressOf RefreshCity)
thread_refreshcontact.Name = "vendorcity"
thread_refreshcontact.IsBackground = True

thread_refreshcontact.Start()
Catch ex As Exception
MsgBox(ex.ToString)
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.ToString)
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
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...
11
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...
12
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. ...
16
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
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...
2
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...
2
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...
4
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...
2
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...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: 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
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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,...

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.