Stopwatch To pause App ????
-
Just found this:
private void App_Exit(object sender, ExitEventArgs e)
{
ConnectionManager.IConnectionManager.Shutdown() // Disconnect from device
// Wait for 4 sec to check if Connection Manager is shutdown. Else close anyway.
Stopwatch sw = new Stopwatch();
sw.Start();
while (sw.Elapsed < TimeSpan.FromMilliseconds(4000))
{
// Wait
}
sw.Stop();
}Guess the dev didn't know about
System.Threading.Thread.Sleep(4000);
If it's not broken, fix it until it is
-
Just found this:
private void App_Exit(object sender, ExitEventArgs e)
{
ConnectionManager.IConnectionManager.Shutdown() // Disconnect from device
// Wait for 4 sec to check if Connection Manager is shutdown. Else close anyway.
Stopwatch sw = new Stopwatch();
sw.Start();
while (sw.Elapsed < TimeSpan.FromMilliseconds(4000))
{
// Wait
}
sw.Stop();
}Guess the dev didn't know about
System.Threading.Thread.Sleep(4000);
If it's not broken, fix it until it is
-
Just found this:
private void App_Exit(object sender, ExitEventArgs e)
{
ConnectionManager.IConnectionManager.Shutdown() // Disconnect from device
// Wait for 4 sec to check if Connection Manager is shutdown. Else close anyway.
Stopwatch sw = new Stopwatch();
sw.Start();
while (sw.Elapsed < TimeSpan.FromMilliseconds(4000))
{
// Wait
}
sw.Stop();
}Guess the dev didn't know about
System.Threading.Thread.Sleep(4000);
If it's not broken, fix it until it is
:doh: :laugh:
What do you get when you cross a joke with a rhetorical question? The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism. Do questions with multiple question marks annoy you???
-
Just found this:
private void App_Exit(object sender, ExitEventArgs e)
{
ConnectionManager.IConnectionManager.Shutdown() // Disconnect from device
// Wait for 4 sec to check if Connection Manager is shutdown. Else close anyway.
Stopwatch sw = new Stopwatch();
sw.Start();
while (sw.Elapsed < TimeSpan.FromMilliseconds(4000))
{
// Wait
}
sw.Stop();
}Guess the dev didn't know about
System.Threading.Thread.Sleep(4000);
If it's not broken, fix it until it is
Shouldn't burden of waiting for the disconnect to happen be placed on the Shutdown method? At most the caller should specify the timeout:
ConnectionManager.IConnectionManager.Shutdown(4000)
-
Just found this:
private void App_Exit(object sender, ExitEventArgs e)
{
ConnectionManager.IConnectionManager.Shutdown() // Disconnect from device
// Wait for 4 sec to check if Connection Manager is shutdown. Else close anyway.
Stopwatch sw = new Stopwatch();
sw.Start();
while (sw.Elapsed < TimeSpan.FromMilliseconds(4000))
{
// Wait
}
sw.Stop();
}Guess the dev didn't know about
System.Threading.Thread.Sleep(4000);
If it's not broken, fix it until it is
I found almost this exact code in the splashscreen of an app I inherited responsibility for.... "The app takes too long to start" was the complaint from the customer. In fact the splashscreen sat there burning up CPU cycles as fast as possible performing "sw.Elapsed.TotalMilliseconds < 10000". Then once the 10 seconds had elapsed it closed the splashscreen and *then* started all the application init tasks (DB connection, load config etc...) I replaced the stopwatch with: - a background thread to perform the app init (which normally took about 7 seconds) - a thead.sleep to "pad" the splashscreen's lifespan up to 10 seconds Apparently a 10-second splashscreen was desired, but cramming the app init into that 10 seconds cured the customer's "slow app" nicely.
-
I found almost this exact code in the splashscreen of an app I inherited responsibility for.... "The app takes too long to start" was the complaint from the customer. In fact the splashscreen sat there burning up CPU cycles as fast as possible performing "sw.Elapsed.TotalMilliseconds < 10000". Then once the 10 seconds had elapsed it closed the splashscreen and *then* started all the application init tasks (DB connection, load config etc...) I replaced the stopwatch with: - a background thread to perform the app init (which normally took about 7 seconds) - a thead.sleep to "pad" the splashscreen's lifespan up to 10 seconds Apparently a 10-second splashscreen was desired, but cramming the app init into that 10 seconds cured the customer's "slow app" nicely.
I always thought the purpose of the splashscreen was to distract the user from how long the app took to get initialised. Back in the day when I did such things, my strategy was for the mainline of the app to throw out a splashscreen, do the grunt work of initialisation then kill the splashscreen. Cheers, Peter
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
-
I always thought the purpose of the splashscreen was to distract the user from how long the app took to get initialised. Back in the day when I did such things, my strategy was for the mainline of the app to throw out a splashscreen, do the grunt work of initialisation then kill the splashscreen. Cheers, Peter
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
Intent and reality intersect far too rarely.
"There are three kinds of lies: lies, damned lies and statistics." - Benjamin Disraeli