Process works in step mode(debugging) only??

T

trint

I have a thread:

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

then another function that only works if in debug mode...I thought it
just needed slowing down, but that didn't work either.
It happens in a do loop:

do{ <--works only in debug mode.
//do something
Thread.Sleep(1000);
} while (couNTer1 == false);

Any help is appreciated.
Thanks,
Trint
 
P

PMGuy

Need more information. What exactly isn't working?

Commonly, when a threaded process works only in debug mode, it's
because a dependent process gets ahead of it. It's a synchronization
problem.

But I'm not sure anyone will be able to help you without having more
information about the problem.
 
T

trint

I want it to stay in this do loop, but if it isn't in debug "stepping",
it breaks on it's own:

bool couNTer1 = false;
do
{
Form1 findThread = new Form1();
findThread.label15.Text = ("0" + " Invoices Left to Print");
findThread.loadInvoiceContainer();
findThread.label15.Text = (Convert.ToString(Class1.cI) + "
Invoices Left to Print");
findThread.button7.Text = "&Watching for New Invoices";


if(Class1.cI > 0)
{
findThread.gotoForeach();
}
} while (couNTer1 == false);
Thanks,
Trint
 
A

Adam Clauss

trint said:
I want it to stay in this do loop, but if it isn't in debug "stepping",
it breaks on it's own:

bool couNTer1 = false;
do
{
Form1 findThread = new Form1();
findThread.label15.Text = ("0" + " Invoices Left to Print");
findThread.loadInvoiceContainer();
findThread.label15.Text = (Convert.ToString(Class1.cI) + "
Invoices Left to Print");
findThread.button7.Text = "&Watching for New Invoices";


if(Class1.cI > 0)
{
findThread.gotoForeach();
}
} while (couNTer1 == false);
Thanks,
Trint


Well, for that loop to break out, couNTer1 has to be true. I don't even see
where that happens here... you must have something else going on that you
haven't shown us.
 
T

trint

There is no break in any function within the do loop.
Does a thread have to be told to continue working?
Trint
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

What is what you want to do?
A thread will live as long as the method being executed is running, when it
ends the thread cease of exist.

It seems that you want to do some processing in the background as wait for
invoices & print them.

How the invoices are received? Have you tried the FileWatcher class?

cheers,
 
T

Trint Smith

I figured it out...I was trying to access a UI control in one of the
functions.
Thanks,
Trint

.Net programmer
(e-mail address removed)
 
W

Willy Denoyette [MVP]

trint said:
There is no break in any function within the do loop.
Does a thread have to be told to continue working?
Trint
So you endlessly (or until it crashes!) create instances of Form1, call
loadInvoiceContainer() and possibly (if Class1.cI != 0) you call
gotoForeach().
I suppose "Class1.cI" is set to non-zero in your background thread, but
before this one gets a chance to run you might have run the loop a thousands
times, simply wasting CPU and memory resources, until it crashes, right?.

Willy.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top