Click here to Skip to main content
15,887,027 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Send Keys to another application (Hard one) Pin
Kobi_Z4-Aug-09 21:53
Kobi_Z4-Aug-09 21:53 
GeneralNOT WORKING Pin
Kobi_Z5-Aug-09 18:40
Kobi_Z5-Aug-09 18:40 
GeneralRe: Send Keys to another application (Hard one) Pin
Kobi_Z6-Aug-09 6:48
Kobi_Z6-Aug-09 6:48 
QuestionMy First Post so be gentle ;) Problem stoppiong code from running in a closed form Pin
William Ralls4-Aug-09 7:01
William Ralls4-Aug-09 7:01 
AnswerRe: My First Post so be gentle ;) Problem stoppiong code from running in a closed form Pin
nlarson114-Aug-09 7:23
nlarson114-Aug-09 7:23 
AnswerRe: My First Post so be gentle ;) Problem stoppiong code from running in a closed form Pin
N a v a n e e t h4-Aug-09 7:43
N a v a n e e t h4-Aug-09 7:43 
GeneralRe: My First Post so be gentle ;) Problem stoppiong code from running in a closed form Pin
William Ralls4-Aug-09 9:00
William Ralls4-Aug-09 9:00 
GeneralRe: My First Post so be gentle ;) Problem stoppiong code from running in a closed form Pin
Luc Pattyn4-Aug-09 15:00
sitebuilderLuc Pattyn4-Aug-09 15:00 
Hi,

first of all:
1) welcome to the CodeProject
2) IMO most replies you've got are not touching the heart of the problem you have.

Here is how I see it: there are basically three problems.

1) you have a potentially slow calculation executed inside the frmAmort_Load() method; this is bad, since it will block normal GUI operations for as long as it takes. A typical GUI guideline says you should make sure the GUI always responds "immediately", meaning no handler should ever take more than say 30 msec to execute. If more work needs to be done, you should delegate that to another thread (and take the required actions to get the data correctly to the GUI Controls).

2) to "remedy" (or really: hide part of) the problem, you have added an Application.DoEvents() call which makes sure some Controls get updated before the handler is done (that is what you wanted), however it also will process whatever other Windows messages it can find, such as the clicking of the close box. That is how you are able to close the form that is still being loaded.

3) you have a Thread.Sleep inside a handler, that is a big no no. You should NEVER do that, for the very same reasons mentioned above.

Here is what you should do as a minimum:
1) remove the Thread.Sleep
2) replace the Application.DoEvents() by either nothing or by lstAmort.Refresh()
(chances are without the Sleep, the entire Load is almost instantaneous, unless you need hundreds of lines in the list)

And here is what a decent approach would be assuming a really long calculation;
1) the above minimum fixes;
2) plus moving most of the Load stuff to a BackgroundWorker, and using Control.Invoke to update the lstAmort Control. See this article[^] of mine, and the BGW documentation.

Smile | :)

Luc Pattyn [Forum Guidelines] [My Articles]

The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.

AnswerDataGridView Pin
David Mujica4-Aug-09 8:04
David Mujica4-Aug-09 8:04 
AnswerRe: My First Post so be gentle ;) Problem stoppiong code from running in a closed form Pin
Christian Graus4-Aug-09 13:24
protectorChristian Graus4-Aug-09 13:24 
QuestionHow to check if TCP/IP connection is active with a device Pin
sohaib_a4-Aug-09 5:26
sohaib_a4-Aug-09 5:26 
AnswerRe: How to check if TCP/IP connection is active with a device Pin
N a v a n e e t h4-Aug-09 7:45
N a v a n e e t h4-Aug-09 7:45 
GeneralRe: How to check if TCP/IP connection is active with a device Pin
sohaib_a4-Aug-09 11:42
sohaib_a4-Aug-09 11:42 
QuestionHot to read uncommon picture format? Pin
Sonhospa4-Aug-09 0:22
Sonhospa4-Aug-09 0:22 
AnswerRe: Hot to read uncommon picture format? Pin
Luc Pattyn4-Aug-09 1:16
sitebuilderLuc Pattyn4-Aug-09 1:16 
GeneralRe: Hot to read uncommon picture format? Pin
Sonhospa4-Aug-09 6:26
Sonhospa4-Aug-09 6:26 
GeneralRe: Hot to read uncommon picture format? Pin
Luc Pattyn4-Aug-09 6:52
sitebuilderLuc Pattyn4-Aug-09 6:52 
GeneralRe: Hot to read uncommon picture format? Pin
Sonhospa4-Aug-09 8:32
Sonhospa4-Aug-09 8:32 
GeneralRe: Hot to read uncommon picture format? Pin
Luc Pattyn4-Aug-09 8:44
sitebuilderLuc Pattyn4-Aug-09 8:44 
GeneralRe: Hot to read uncommon picture format? Pin
Sonhospa4-Aug-09 9:47
Sonhospa4-Aug-09 9:47 
AnswerRe: Hot to read uncommon picture format? Pin
Steven J Jowett4-Aug-09 3:49
Steven J Jowett4-Aug-09 3:49 
GeneralRe: Hot to read uncommon picture format? Pin
Sonhospa4-Aug-09 6:31
Sonhospa4-Aug-09 6:31 
Questionconnecting gmail using IMAP in VB.NET? Pin
nevincm3-Aug-09 21:16
nevincm3-Aug-09 21:16 
AnswerRe: connecting gmail using IMAP in VB.NET? Pin
Mike Ellison4-Aug-09 3:17
Mike Ellison4-Aug-09 3:17 
QuestionBest practices for common routines Pin
supercat93-Aug-09 12:36
supercat93-Aug-09 12:36 

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.