Click here to Skip to main content
15,913,836 members
Home / Discussions / C#
   

C#

 
AnswerRe: need to write a code in C++ to take a pic and save it in bitmap Pin
Member 961-Feb-07 13:23
Member 961-Feb-07 13:23 
GeneralRe: need to write a code in C++ to take a pic and save it in bitmap Pin
ricardo montemayor1-Feb-07 13:48
ricardo montemayor1-Feb-07 13:48 
GeneralRe: need to write a code in C++ to take a pic and save it in bitmap Pin
Member 961-Feb-07 14:04
Member 961-Feb-07 14:04 
GeneralRe: need to write a code in C++ to take a pic and save it in bitmap Pin
ricardo montemayor1-Feb-07 17:12
ricardo montemayor1-Feb-07 17:12 
QuestionDatabase testing Pin
sreecahitu1-Feb-07 11:27
sreecahitu1-Feb-07 11:27 
AnswerRe: Database testing Pin
Judah Gabriel Himango1-Feb-07 13:34
sponsorJudah Gabriel Himango1-Feb-07 13:34 
Question[Message Deleted] Pin
nobody26261-Feb-07 10:45
nobody26261-Feb-07 10:45 
AnswerRe: StackTrace on main UI thread causes System.ExecutionEngineException Pin
Luc Pattyn1-Feb-07 11:57
sitebuilderLuc Pattyn1-Feb-07 11:57 
Hi,

I have not done StackTrace stuff like that, but here are some facts and ideas:

1)
the documentation says "If a StackTrace is created with a target thread that is not the
current thread, the target thread must first be suspended"
Well, suspending the UI thread is not a good idea (if it is all possible); and I would
not be surprised if you would fail to suspend it when your app is "Not Responding".
Anyway it sounds like a bad idea if you already have UI problems...

2)
AFAIK the "Not Responding" mechanism is as follows: Windows kernel periodically sends a special
WM_xxx command to each application, and expects a return message within a short delay
(similar to the ping protocol over a network). Normally that message gets handled by the
message pump (normally the UI thread), unless the app is too busy (long calculation
on UI thread), is waiting on something, or hangs in any other way.

3)
This also means I cannot predict the ThreadState of your UI thread.

4)
Thread priorities:
if your app uses multiple threads, carefully choose their priority; at or below normal
should not pose problems; above normal should be used carefully, and real-time is to
be avoided (except for short and very specific loop- and wait-free code).
Rationale: when two threads are ready to run, Windows would allot most CPU cycles to
the highest priority one, and some CPU cycles to the lower priority one too, but if that
is the UI thread you would call it unacceptable responsiveness. (And I expect this to
be even worse on a Windows Server OS).
A real-time thread would consume all CPU cycles.

5)
sometimes a small UI problem can be solved by including some
Application.DoEvents(); statements inside a busy loop. I am not sure this is a clean
solution, but it occassionally improves the UI behavior.

6)
My advise: try one or more of the following:
- watch the Task Manager's "Performance" tab while your app is, if possible, the only one
really running. If CPU load is high, it looks like either real calculation, or a polling
loop that lacks a delay; if they are in the UI thread, they should be moved in another thread;
if they occur in a higher priority thread, they would severely reduce UI responsiveness.
- use some other observation tool (e.g. "task info", not part of Windows) that can give you
an indication of CPU load per thread; although identifying threads within a process is
not easy, I expect the UI thread to be the first (or one of the first).
- run your app inside Visual Studio, pref. in debug mode, and pause the app while the
non-responsiveness begins; if this brings up a source file (or a useful call stack)
that is the suspect code.
- if you can find the code that causes the problem:
if it is real calculations, they must move to another thread, with a priority at or
below normal; if it is a wait (anything that blocks or could block), it does not belong
in the UI thread. The UI thread should never block ! (I know this is not easy, it also
means it should not lock).

Hope this helps

Smile | :)




Luc Pattyn

QuestionURI-Formats are not supported Pin
Hunv1-Feb-07 9:20
Hunv1-Feb-07 9:20 
AnswerRe: URI-Formats are not supported Pin
Guffa1-Feb-07 10:36
Guffa1-Feb-07 10:36 
AnswerRe: URI-Formats are not supported Pin
Luc Pattyn1-Feb-07 12:13
sitebuilderLuc Pattyn1-Feb-07 12:13 
Questionsting format problem-need quick help Pin
adnanrafiq1-Feb-07 8:11
adnanrafiq1-Feb-07 8:11 
AnswerRe: sting format problem-need quick help Pin
Luc Pattyn1-Feb-07 8:22
sitebuilderLuc Pattyn1-Feb-07 8:22 
GeneralRe: sting format problem-need quick help Pin
adnanrafiq1-Feb-07 8:38
adnanrafiq1-Feb-07 8:38 
GeneralRe: sting format problem-need quick help Pin
Pradipta Basu1-Feb-07 9:15
Pradipta Basu1-Feb-07 9:15 
QuestionCheck Application Pin
The Brazilian One1-Feb-07 7:58
The Brazilian One1-Feb-07 7:58 
AnswerRe: Check Application Pin
Stefan Troschuetz1-Feb-07 8:22
Stefan Troschuetz1-Feb-07 8:22 
AnswerRe: Check Application Pin
Luc Pattyn1-Feb-07 8:23
sitebuilderLuc Pattyn1-Feb-07 8:23 
QuestionGraphic library Pin
Michael O.1-Feb-07 7:22
Michael O.1-Feb-07 7:22 
AnswerRe: Graphic library Pin
Luc Pattyn1-Feb-07 8:26
sitebuilderLuc Pattyn1-Feb-07 8:26 
AnswerRe: Graphic library Pin
Christian Graus1-Feb-07 9:23
protectorChristian Graus1-Feb-07 9:23 
AnswerRe: Graphic library Pin
Michael O.1-Feb-07 12:26
Michael O.1-Feb-07 12:26 
GeneralRe: Graphic library Pin
Christian Graus1-Feb-07 14:39
protectorChristian Graus1-Feb-07 14:39 
Question[C# .NET 2.0 VS 2005] deserializer problem : attributes are null ? [modified] Pin
Fabrice Deshayes aka Xtream1-Feb-07 6:52
Fabrice Deshayes aka Xtream1-Feb-07 6:52 
QuestionSeemingly seperate strings point to same object Pin
crunchi1-Feb-07 6:25
crunchi1-Feb-07 6:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.