time counter

  • Thread starter Thread starter Ignacio Martinez
  • Start date Start date
I

Ignacio Martinez

Hey group! I've been developing ASP.NET App's for quite a long time, and
just about a month ago I started with windows forms and I'm kinda new to
some methods and techniques.

In this particular case I find myself with a form that runs a process that
takes about 2 to 3 minutes, and I can't use a Progress bar to show the work
that's being done because I don't loop the process on the front-end (it's
all being done on a second tier), so I can't tell in what instance of it I
am at any moment. So I thought of using a time counter. Two questions come
to my mind when I think of this:

1) Do I need the Timer control for this particular case?
2) How do I show the timer counting as I'm running a process? Do I need to
use threads?

I don't know if Threading is the answer because this is a syncronic process.
The timer stops when the process finishes.

Any ideas?????
Thanx in advance.
Ignacio.
 
Welcome to the fascinating world of windows programming!
Web programmming is too dry and you 'll not learn
interesting things such as thread programming, thread
synchronization, interprocess commmunication etc .
Well thats too much of an itroduction.

You should really use threads in this case.

You can spawn a thread, and in which you can do this
process which takes 2-3 minutes, and also you can update
the progressbar from this thread, which has the advantage
that it will free the gui thread.

// To spawn a thread quickly ;-)
Thread newThr = new Thread(new ThreadStart
(this.Threadproc));
newThr.Start();
 
sunil, thanx for answering.
I'll look over some doc. on threading to start with, before I dive into it.
the 2nd question has been solved, but the 1st still keeps me a bit worried
and/or curious.

how do I show time counting on a form? (00:00:01 an so on, second by second)
and how do I handle a thread completion from another thread?

thanx again!!!!
ignacio.
buenos aires, argentina
 
For time counting, you can use a Timer.
You can control the state of a thread by calling Thread
object's methods such as

Suspend()
Abort()
Resume()
Join()

pls have a look at msdn and you're done.
 
Back
Top