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

Threading

Hello,

I have the following problem:
I'm making a application that add at runtime usercontrols.
Each usercontrol have a function that converts a image.
This conversion takes a while and at the time the function is running the
applications blocks.
So I want to implement Threading but only for the moment this function is
running.
I have to pass arguments to the function like width, height,...

How can I prevent that the application doesn't block when this function is
running?

Thanks in advance.
Nov 15 '05 #1
2 4734
You answered your own question: by starting a thread..

You can't send ThreadStart any arguments, so what most people do - is create
a class, that will do the thread work.. so in psuedo-code:

-create an instance of the threadworker class (call it objWorker)
-assign height, width, other properties to objWorker
-create a thread, and assign it to objWorker.DoWork()

hth

"Fredje" <co*****@hotmail.com> wrote in message
news:Gk******************@afrodite.telenet-ops.be...
Hello,

I have the following problem:
I'm making a application that add at runtime usercontrols.
Each usercontrol have a function that converts a image.
This conversion takes a while and at the time the function is running the
applications blocks.
So I want to implement Threading but only for the moment this function is
running.
I have to pass arguments to the function like width, height,...

How can I prevent that the application doesn't block when this function is
running?

Thanks in advance.

Nov 15 '05 #2
You can pass back created picture or controls to UI thread. Just remember,
that you can't update UI thread controls (main form) reliably from another
thread. Take a look at InvokeRequired and Invoke/BeginInvoke methods of
Control object.

HTH
Alex

"Fredje" <co*****@hotmail.com> wrote in message
news:qm*******************@phobos.telenet-ops.be...
Thank you very much.

This already working.
The result of the function is a picture. This picture must be placed in a
picturebox in the parent of the class objWorker. I've solved this now by
passing the picturebox form the parent width the constructor of the object
objWorker.
Is this a good way of working?

I want also when the function is completed width running the tread stops and dipose.
But before the tread dipose the image must be saved.
Is it better that is do this from the object objWorker or from the parent?

Thank you again

"Drebin" <tR*************@hotmail.com> wrote in message
news:Nn**********************@newssvr28.news.prodi gy.com...
You answered your own question: by starting a thread..

You can't send ThreadStart any arguments, so what most people do - is create
a class, that will do the thread work.. so in psuedo-code:

-create an instance of the threadworker class (call it objWorker)
-assign height, width, other properties to objWorker
-create a thread, and assign it to objWorker.DoWork()

hth

"Fredje" <co*****@hotmail.com> wrote in message
news:Gk******************@afrodite.telenet-ops.be...
Hello,

I have the following problem:
I'm making a application that add at runtime usercontrols.
Each usercontrol have a function that converts a image.
This conversion takes a while and at the time the function is running the applications blocks.
So I want to implement Threading but only for the moment this function is running.
I have to pass arguments to the function like width, height,...

How can I prevent that the application doesn't block when this
function is running?

Thanks in advance.



Nov 15 '05 #3

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:...
1
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: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
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...

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.