473,320 Members | 1,950 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.

multi-threading problem...help

Ok,
I have a thread that I start when user clicks to start:

ThreadStart myThreadDelegate = new ThreadStart
ThreadFunction1.getOneAtATime);
Thread thr1 = new Thread(myThreadDelegate);
thr1.Start();

The process started contains a Very large function that is in a
continuous loop (here is part of it just to demonstrate my problem):

foreach (string invoice in Class1.invoiceHolder)
{
//Constantly show a status bar
//Constantly update image control of "if tray has paper or not".
//Constantly update labels displaying info about Invoices
}

Ok,
This will need to run for days at a time in this loop...HOWEVER, I had
it in the Thread, as mentioned, and the app would just quit.
I had posted a question to this before and got the answer that
"Controls created by the initializing thread should not be touched by
processes started in other threads (creates undesirable results". Ok,
I get that, but when this thread I start runs, it MUST give updates to
users.
Ok, I have looked at Control.Invoke and don't get it. I mean that, I
couldn't figure out how to use it (mental block). Is that the answer to
my problem? (Problem being, that if I don't start this giant process in
a separate thread, when it starts in this loop, the computer starts to
crawl).
Help is appreciated.
Thanks,
Trint

Nov 17 '05 #1
9 1158
I whould start two thread, one that do the work, and one (using timers)
that updates the status to the user every xxx time.

But... why don't you do a service that comunicate with a front-end with
QueueMessage or other tecnics?

Nov 17 '05 #2
Not a bad idea, but they have already approved the look of the controls
on the forms.
I do need to have this large function in a new thread though.
Thanks.

Nov 17 '05 #3
VJ
Hi Trint..

This article is in VB and explains pretty much about threads and passing
values between them, see if it helps

http://www.devx.com/dotnet/Article/11358/1954?pf=true

VJ

"trint" <tr***********@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
Not a bad idea, but they have already approved the look of the controls
on the forms.
I do need to have this large function in a new thread though.
Thanks.

Nov 17 '05 #4
trint <tr***********@gmail.com> wrote:
I have a thread that I start when user clicks to start:

ThreadStart myThreadDelegate = new ThreadStart
ThreadFunction1.getOneAtATime);
Thread thr1 = new Thread(myThreadDelegate);
thr1.Start();

The process started contains a Very large function that is in a
continuous loop (here is part of it just to demonstrate my problem):


<snip>

See http://www.pobox.com/~skeet/csharp/t...winforms.shtml

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 17 '05 #5
Lock the control in your worker thread, as stated in the article provided at
pobox.com. That will force all of your UI updates through a single thread.

"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
trint <tr***********@gmail.com> wrote:
I have a thread that I start when user clicks to start:

ThreadStart myThreadDelegate = new ThreadStart
ThreadFunction1.getOneAtATime);
Thread thr1 = new Thread(myThreadDelegate);
thr1.Start();

The process started contains a Very large function that is in a
continuous loop (here is part of it just to demonstrate my problem):


<snip>

See http://www.pobox.com/~skeet/csharp/t...winforms.shtml

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 17 '05 #6
Alex Passos <bz@netmerlin.nospam.com> wrote:
Lock the control in your worker thread, as stated in the article provided at
pobox.com. That will force all of your UI updates through a single thread.


No it won't! Locking the control doesn't change what thread method
calls go through - you need to use Control.Invoke.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 17 '05 #7
Jon,
I am trying to figure out how to apply your info on threading with
controls to my application...I may need more help...are you still
there?
Thanks,
Trint

Nov 17 '05 #8
> I am trying to figure out how to apply your info on threading with
controls to my application...I may need more help...are you still
there?


I'm at work, and only very occasionally checking the group, but I'll be
posting more tonight (UK time) and in the early morning. Put it this
way - I'm almost always bound to reply within 24 hours :)

Jon

Nov 17 '05 #9
Jon,
Could you take a look?

http://groups.google.com/group/micro...5362ffb46f97f6

Thanks,
Trint

Nov 17 '05 #10

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

Similar topics

4
by: OutsiderJustice | last post by:
Hi All, I can not find any information if PHP support multi-thread (Posix thread) or not at all, can someone give out some information? Is it supported? If yes, where's the info? If no, is it...
12
by: * ProteanThread * | last post by:
but depends upon the clique: ...
6
by: cody | last post by:
What are multi file assemblies good for? What are the advantages of using multiple assemblies (A.DLL+B.DLL) vs. a single multi file assembly (A.DLL+A.NETMODULE)?
2
by: ip4ram | last post by:
I used to work with C and have a set of libraries which allocate multi-dimensional arrays(2 and 3) with single malloc call. data_type **myarray =...
6
by: Joe | last post by:
I have 2 multi-list boxes, 1 displays course categories based on a table called CATEGORIES. This table has 2 fields CATEGORY_ID, CATEGORY_NAME The other multi-list box displays courses based on...
1
by: Bob Rock | last post by:
Hello, I was wondering when multi-file assemblies may be useful. With multi-file assemblies you may place inside the same assembly netmodules coded in different languages and as a consequence...
5
by: bobwansink | last post by:
Hi, I'm relatively new to programming and I would like to create a C++ multi user program. It's for a project for school. This means I will have to write a paper about the theory too. Does anyone...
0
by: Sabri.Pllana | last post by:
We apologize if you receive multiple copies of this call for papers. *********************************************************************** 2008 International Workshop on Multi-Core Computing...
1
by: mknoll217 | last post by:
I am recieving this error from my code: The multi-part identifier "PAR.UniqueID" could not be bound. The multi-part identifier "Salary.UniqueID" could not be bound. The multi-part identifier...
4
by: =?Utf-8?B?SGVucmlrIFNjaG1pZA==?= | last post by:
Hi, consider the attached code. Serializing the multi-dimensional array takes about 36s vs. 0.36s for the single-dimensional array. Initializing the multi-dimensional array takes about 4s...
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
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
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: 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...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
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)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
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.