By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
460,028 Members | 1,258 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 460,028 IT Pros & Developers. It's quick & easy.

Program runs under debug mode but stalls in normal mode

P: n/a
Hi,

I am new to c#. I am trying to build an application that does backup
of files to an external hard disk.

My application behaves strangely. When i run the application under
debug mode (F5), it works properly. But when i run it in normal mode
(Ctrl+F5) the program stalls in the middle.

I use a couple of worker threads which run successively. The first one
is for estimating the space requirements - calculating the folder size
to backup and also finding the available disk space on the external
hard disk.

After the first thread completes, the second worker thread does the
actual backup. The main thread handles the UI. The two worker threads
update the UI components in the main thread in a thread safe manner.

All these work properly in the debug mode. But in the normal mode, the
program stalls during the backup. It stops in the middle and the
backup does not complete. Also, the program does not respond.

FYI, I am building the application under "debug" and not "release"
configuration.

Any help appreciated.

Thank you.

Aug 31 '07 #1
Share this Question
Share on Google+
8 Replies


P: n/a
Jothishankar wrote:
I am new to c#. I am trying to build an application that does backup
of files to an external hard disk.

My application behaves strangely. When i run the application under
debug mode (F5), it works properly. But when i run it in normal mode
(Ctrl+F5) the program stalls in the middle.
Well, what is it doing when it stalls? You can attach the debugger to
the process and examine the state of the program, which should tell you
where it has stalled.

Based on your description of the program, I suspect you have an error in
your threading code and have created a deadlock situation somewhere.
But the first step, whatever the problem, is for you to get a stack
trace and figure out exactly where the program is stuck.

Pete
Aug 31 '07 #2

P: n/a
Hi,

"Jothishankar" <sh*******@gmail.comwrote in message
news:11*********************@r29g2000hsg.googlegro ups.com...
Hi,

I am new to c#. I am trying to build an application that does backup
of files to an external hard disk.

My application behaves strangely. When i run the application under
debug mode (F5), it works properly. But when i run it in normal mode
(Ctrl+F5) the program stalls in the middle.

I use a couple of worker threads which run successively. The first one
is for estimating the space requirements - calculating the folder size
to backup and also finding the available disk space on the external
hard disk.

After the first thread completes, the second worker thread does the
actual backup. The main thread handles the UI. The two worker threads
update the UI components in the main thread in a thread safe manner.

What you mean with a Thread safe mode?
Are you using Control.Invoke to update the UI?

Aug 31 '07 #3

P: n/a
On Aug 31, 12:50 pm, "Ignacio Machin \( .NET/ C# MVP \)" <machin TA
laceupsolutions.comwrote:
Hi,

"Jothishankar" <shanka...@gmail.comwrote in message

news:11*********************@r29g2000hsg.googlegro ups.com...
Hi,
I am new to c#. I am trying to build an application that does backup
of files to an external hard disk.
My application behaves strangely. When i run the application under
debug mode (F5), it works properly. But when i run it in normal mode
(Ctrl+F5) the program stalls in the middle.
I use a couple of worker threads which run successively. The first one
is for estimating the space requirements - calculating the folder size
to backup and also finding the available disk space on the external
hard disk.
After the first thread completes, the second worker thread does the
actual backup. The main thread handles the UI. The two worker threads
update the UI components in the main thread in a thread safe manner.

What you mean with a Thread safe mode?
Are you using Control.Invoke to update the UI?
Yes. I am using Invoke to update the UI.

Aug 31 '07 #4

P: n/a
On Aug 31, 11:55 am, Peter Duniho <NpOeStPe...@NnOwSlPiAnMk.com>
wrote:
Jothishankar wrote:
I am new to c#. I am trying to build an application that does backup
of files to an external hard disk.
My application behaves strangely. When i run the application under
debug mode (F5), it works properly. But when i run it in normal mode
(Ctrl+F5) the program stalls in the middle.

Well, what is it doing when it stalls? You can attach the debugger to
the process and examine the state of the program, which should tell you
where it has stalled.

Based on your description of the program, I suspect you have an error in
your threading code and have created a deadlock situation somewhere.
But the first step, whatever the problem, is for you to get a stack
trace and figure out exactly where the program is stuck.

Pete
If there is a deadlock situation in the code, shouldn't it come up
when i run it the debug mode? I have tested it many times, and this
does not happen when i run in debug mode.

After running the program (Ctrl+F5), i attached the process to the
debugger. But the debugger does not give anything related to the
stalling. It is as if the program is running normally. But although, i
am curious as to why my threads do not show up in the Thread window of
the debugger.

Aug 31 '07 #5

P: n/a
Aside from other valid suggestions like attaching debugger, I'd suggest that
you try to wire up your code better for exception handling and logging. If
you have good exception handling and can log any exceptions to a file, the
event log, or to a database (including code that catches and logs the
unhandled exception events) then you'll be in a position to get better
metrics about what is going on. Finally, don't run a debug build to do this
testing - make a release build.
-- Peter
Recursion: see Recursion
site: http://www.eggheadcafe.com
unBlog: http://petesbloggerama.blogspot.com
BlogMetaFinder: http://www.blogmetafinder.com

"Peter Duniho" wrote:
Jothishankar wrote:
I am new to c#. I am trying to build an application that does backup
of files to an external hard disk.

My application behaves strangely. When i run the application under
debug mode (F5), it works properly. But when i run it in normal mode
(Ctrl+F5) the program stalls in the middle.

Well, what is it doing when it stalls? You can attach the debugger to
the process and examine the state of the program, which should tell you
where it has stalled.

Based on your description of the program, I suspect you have an error in
your threading code and have created a deadlock situation somewhere.
But the first step, whatever the problem, is for you to get a stack
trace and figure out exactly where the program is stuck.

Pete
Aug 31 '07 #6

P: n/a
On Aug 31, 3:30 pm, Peter Bromberg [C# MVP]
<pbromb...@yahoo.yohohhoandabottleofrum.comwrote :
Aside from other valid suggestions like attaching debugger, I'd suggest that
you try to wire up your code better for exception handling and logging. If
you have good exception handling and can log any exceptions to a file, the
event log, or to a database (including code that catches and logs the
unhandled exception events) then you'll be in a position to get better
metrics about what is going on. Finally, don't run a debug build to do this
testing - make a release build.
-- Peter
Recursion: see Recursion
site: http://www.eggheadcafe.com
unBlog: http://petesbloggerama.blogspot.com
BlogMetaFinder: http://www.blogmetafinder.com

"Peter Duniho" wrote:
Jothishankar wrote:
I am new to c#. I am trying to build an application that does backup
of files to an external hard disk.
My application behaves strangely. When i run the application under
debug mode (F5), it works properly. But when i run it in normal mode
(Ctrl+F5) the program stalls in the middle.
Well, what is it doing when it stalls? You can attach the debugger to
the process and examine the state of the program, which should tell you
where it has stalled.
Based on your description of the program, I suspect you have an error in
your threading code and have created a deadlock situation somewhere.
But the first step, whatever the problem, is for you to get a stack
trace and figure out exactly where the program is stuck.
Pete
I cannot get the stack trace because, the program runs properly 100%
of the time in debug mode. Only when i run it in normal mode, this
problem happens. I also did a "Attach to Process", but that also does
not give any debug info.

Sep 4 '07 #7

P: n/a
On Sep 4, 2:35 pm, Jothishankar <shanka...@gmail.comwrote:
On Aug 31, 3:30 pm, Peter Bromberg [C# MVP]

<pbromb...@yahoo.yohohhoandabottleofrum.comwrote :
Aside from other valid suggestions like attaching debugger, I'd suggest that
you try to wire up your code better for exception handling and logging. If
you have good exception handling and can log any exceptions to a file, the
event log, or to a database (including code that catches and logs the
unhandled exception events) then you'll be in a position to get better
metrics about what is going on. Finally, don't run a debug build to do this
testing - make a release build.
-- Peter
Recursion: see Recursion
site: http://www.eggheadcafe.com
unBlog: http://petesbloggerama.blogspot.com
BlogMetaFinder: http://www.blogmetafinder.com
"Peter Duniho" wrote:
Jothishankar wrote:
I am new to c#. I am trying to build an application that does backup
of files to an external hard disk.
My application behaves strangely. When i run the application under
debug mode (F5), it works properly. But when i run it in normal mode
(Ctrl+F5) the program stalls in the middle.
Well, what is it doing when it stalls? You can attach the debugger to
the process and examine the state of the program, which should tell you
where it has stalled.
Based on your description of the program, I suspect you have an error in
your threading code and have created a deadlock situation somewhere.
But the first step, whatever the problem, is for you to get a stack
trace and figure out exactly where the program is stuck.
Pete

I cannot get the stack trace because, the program runs properly 100%
of the time in debug mode. Only when i run it in normal mode, this
problem happens. I also did a "Attach to Process", but that also does
not give any debug info.
Finally, i have figured out what the problem was. I am using a
DataGrid control to show the status of the backup process. I did not
make that thread safe. That was causing the whole problem. After
correcting that (by calling the Invoke the DataGrid control), it works
fine.

I have a separate question with regards to the the DataGrid control.
How can i make it scroll automatically when i add rows to the
DataTable object which is the datasource for the DataGrid ?

Thanks

Sep 5 '07 #8

P: n/a
Jothishankar wrote:
[...]
I have a separate question with regards to the the DataGrid control.
How can i make it scroll automatically when i add rows to the
DataTable object which is the datasource for the DataGrid ?
A suggestion: if you are going to ask a new question completely
different from your original, start a new thread.

This is always a good idea, but even more so when your original question
was fairly esoteric and thus much more likely to be ignored by a wider
audience.

Pete
Sep 5 '07 #9

This discussion thread is closed

Replies have been disabled for this discussion.