473,320 Members | 2,012 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,320 software developers and data experts.

VB.net and threading

All,
I am developing a vb.net using threading....
I have a button to print a doc (it takes about 5-10 seconds to finish that
process). As soon I click that button I start a thread and then I go to a
different tab to do other stuff....But while printing it prevents me from
doing other stuff (UI looks like freeze)...make me wait before printing is
finished. I thought the thread will solve this problem for me but it
doesn’t....Please advice. Thanks

Jan 15 '08 #1
4 2119
On 2008-01-15, hngo01 <hn****@discussions.microsoft.comwrote:
All,
I am developing a vb.net using threading....
I have a button to print a doc (it takes about 5-10 seconds to finish that
process). As soon I click that button I start a thread and then I go to a
different tab to do other stuff....But while printing it prevents me from
doing other stuff (UI looks like freeze)...make me wait before printing is
finished. I thought the thread will solve this problem for me but it
doesn?t....Please advice. Thanks
Code sample please... It's very hard to diagnose these kinds of issues
without seeing what it is your doing. So, post the smallest possible
code sample that demonstrates the issue:

For what is meant by short and complete sample have a look here:
http://www.yoda.arachsys.com/csharp/complete.html

That is very good advice.

Now, I'm going to give some more advice - without looking at the code :)
If you are using VB2005 or greater, don't use an explicit thread for
this. Take a look at the BackgroundWorker component.

--
Tom Shelton
Jan 15 '08 #2
On Jan 15, 9:40*pm, Tom Shelton
<tom_shel...@YOUKNOWTHEDRILLcomcast.netwrote:
On 2008-01-15, hngo01 <hng...@discussions.microsoft.comwrote:
All,
I am developing a vb.net using threading....
I have a button to print a doc (it takes about 5-10 seconds to finish that
process). *As soon I click that button I start a thread and then I go to a
different tab to do other stuff....But while printing it prevents me from
doing other stuff (UI looks like freeze)...make me wait before printing is
finished. *I thought the thread will solve this problem for me but it
doesn?t....Please advice. Thanks

Code sample please... *It's very hard to diagnose these kinds of issues
without seeing what it is your doing. *So, post the smallest possible
code sample that demonstrates the issue:

For what is meant by short and complete sample have a look here:http://www..yoda.arachsys.com/csharp/complete.html

That is very good advice.

Now, I'm going to give some more advice - without looking at the code :)
If you are using VB2005 or greater, don't use an explicit thread for
this. *Take a look at the BackgroundWorker component.

--
Tom Shelton
Hi dear Tom,
I was seeking a similar help about multi-threading then came accross
Background Worker. My question is: Does background worker do
everything that a separated thread can do? In some of my apps, if i
run external processes or functions, UI (form) seems frozen and screen
is distorted. However in rare cases, background worker helps, but
although i use Background Worker, i sometimes get an multi-threading
error like "cross thread operation is not valid" although my code is
in background workers_doWork event.

What can cause this?

Thanks :-)
Jan 15 '08 #3
On 2008-01-15, kimiraikkonen <ki*************@gmail.comwrote:
On Jan 15, 9:40*pm, Tom Shelton
<tom_shel...@YOUKNOWTHEDRILLcomcast.netwrote:
>On 2008-01-15, hngo01 <hng...@discussions.microsoft.comwrote:
All,
I am developing a vb.net using threading....
I have a button to print a doc (it takes about 5-10 seconds to finish that
process). *As soon I click that button I start a thread and then I go to a
different tab to do other stuff....But while printing it prevents me from
doing other stuff (UI looks like freeze)...make me wait before printing is
finished. *I thought the thread will solve this problem for me but it
doesn?t....Please advice. Thanks

Code sample please... *It's very hard to diagnose these kinds of issues
without seeing what it is your doing. *So, post the smallest possible
code sample that demonstrates the issue:

For what is meant by short and complete sample have a look here:http://www.yoda.arachsys.com/csharp/complete.html

That is very good advice.

Now, I'm going to give some more advice - without looking at the code :)
If you are using VB2005 or greater, don't use an explicit thread for
this. *Take a look at the BackgroundWorker component.

--
Tom Shelton

Hi dear Tom,
I was seeking a similar help about multi-threading then came accross
Background Worker. My question is: Does background worker do
everything that a separated thread can do? In some of my apps, if i
Pretty much - and more. The BackgroundWorker will spawn a new thread of
execution, and if used properly will sync the callbacks for you :)
run external processes or functions, UI (form) seems frozen and screen
is distorted. However in rare cases, background worker helps, but
although i use Background Worker, i sometimes get an multi-threading
error like "cross thread operation is not valid" although my code is
in background workers_doWork event.
You can't directly access your forms controls in the DoWork event. That
event is running on another thread, and will cause the above error to be
generated. If you need to update your UI from the DoWork event, then
you need to call the ReportProgress method from you DoWork event and
handle the ProgressChanged event. It's safe in ProgressChanged, because
the BackgroundWorker takes care of the cross thread marshalling for you.
You can also do any finish up work in the RunWorkerCompleted event...

--
Tom Shelton
Jan 15 '08 #4
Here is my code...

Dim oProcessChanges As New clsProcessChanges 'clsProcess_Changes
Dim t As New Thread(AddressOf oProcessChanges.ProcessChanges)

oProcessChanges.ReqInfo = oReqInfo
oProcessChanges.CurrentValues = oCurrentValues
oProcessChanges.gCourse_ds = CopyDataSet(gCOURSE_DS) 'gDupDataSet
oProcessChanges.pnlControls =
Me.pnlReqInfo.Controls("ucRequestInfo").Controls
oProcessChanges.RequestID =
dgPendingApps.CurrentRow.Cells(dgPendingApps.Colum nCount - 1).Value.ToString
oProcessChanges.AppORReimb = Me.Tag

t.Start()

"Tom Shelton" wrote:
On 2008-01-15, hngo01 <hn****@discussions.microsoft.comwrote:
All,
I am developing a vb.net using threading....
I have a button to print a doc (it takes about 5-10 seconds to finish that
process). As soon I click that button I start a thread and then I go to a
different tab to do other stuff....But while printing it prevents me from
doing other stuff (UI looks like freeze)...make me wait before printing is
finished. I thought the thread will solve this problem for me but it
doesn?t....Please advice. Thanks

Code sample please... It's very hard to diagnose these kinds of issues
without seeing what it is your doing. So, post the smallest possible
code sample that demonstrates the issue:

For what is meant by short and complete sample have a look here:
http://www.yoda.arachsys.com/csharp/complete.html

That is very good advice.

Now, I'm going to give some more advice - without looking at the code :)
If you are using VB2005 or greater, don't use an explicit thread for
this. Take a look at the BackgroundWorker component.

--
Tom Shelton
Jan 16 '08 #5

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

Similar topics

65
by: Anthony_Barker | last post by:
I have been reading a book about the evolution of the Basic programming language. The author states that Basic - particularly Microsoft's version is full of compromises which crept in along the...
2
by: Egor Bolonev | last post by:
hi all my program terminates with error i dont know why it tells 'TypeError: run() takes exactly 1 argument (10 given)' =program==================== import os, os.path, threading, sys def...
77
by: Jon Skeet [C# MVP] | last post by:
Please excuse the cross-post - I'm pretty sure I've had interest in the article on all the groups this is posted to. I've finally managed to finish my article on multi-threading - at least for...
6
by: CK | last post by:
I have the following code in a windows service, when I start the windows service process1 and process2 work fine , but final process (3) doesnt get called. i stop and restart the windows service...
2
by: Vjay77 | last post by:
In this code: Private Sub downloadBtn_Click(ByVal sender As Object, ByVal e As System.EventArgs) If Not (Me.downloadUrlTextBox.Text = "") Then Me.outputGroupBox.Enabled = True...
11
by: Paul Sijben | last post by:
I am stumped by the following problem. I have a large multi-threaded server accepting communications on one UDP port (chosen for its supposed speed). I have been profiling the code and found...
17
by: OlafMeding | last post by:
Below are 2 files that isolate the problem. Note, both programs hang (stop responding) with hyper-threading turned on (a BIOS setting), but work as expected with hyper-threading turned off. ...
0
by: kingcrowbar.list | last post by:
Hello Everyone I have been playing a little with pyGTK and threading to come up with simple alert dialog which plays a sound in the background. The need for threading came when in the first...
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...
126
by: Dann Corbit | last post by:
Rather than create a new way of doing things: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2497.html why not just pick up ACE into the existing standard:...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.