473,770 Members | 1,841 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

computer reset of Power off


Hi
When my application is on, i can't reset or power off computer. Every
program closes but this one....
Why this happens?
PK
Sep 28 '06 #1
6 2316

"PiotrKolodziej " <pi************ *@gmail.comwrot e in message
news:e3******** *************** ****@news.chell o.pl...
|
| Hi
| When my application is on, i can't reset or power off computer. Every
| program closes but this one....
| Why this happens?
| PK
|
|

My guess is that you have another foreground thread running next to the UI
thread. Make this one a background thread.
If you need this thread to clean-up, you'll have to register a
SystemEvents.Se ssionEnding event handler, but make sure you read the remarks
in SystemEvents.Se ssionEnding Event in MSDN.

Willy.

Sep 28 '06 #2
My guess is that you have another foreground thread running next to the UI
thread. Make this one a background thread.
If you need this thread to clean-up, you'll have to register a
SystemEvents.Se ssionEnding event handler, but make sure you read the
remarks
in SystemEvents.Se ssionEnding Event in MSDN.

Willy.
I should give more info - Sorry.
This happens because iam canceling the Close event such that user is not
closing app when X button was clicked.
I tryied to add Environment.Has ShutdownStarted but it not works. When i
disable e.Cancel = true, windows is closing normally.
Have any idea how to bite this?
PK

private void Form1_Closing(o bject sender,
System.Componen tModel.CancelEv entArgs e)
{
this.Visible = false;
this.activated = false;
this.WindowStat e = FormWindowState .Minimized;

if (!Environment.H asShutdownStart ed)
{
// Cancel the close...
e.Cancel = true;
}
}
Sep 28 '06 #3

"PiotrKolodziej " <pi************ *@gmail.comwrot e in message
news:28******** *************** ****@news.chell o.pl...
|
| My guess is that you have another foreground thread running next to the
UI
| thread. Make this one a background thread.
| If you need this thread to clean-up, you'll have to register a
| SystemEvents.Se ssionEnding event handler, but make sure you read the
| remarks
| in SystemEvents.Se ssionEnding Event in MSDN.
| >
| Willy.
|
| I should give more info - Sorry.
| This happens because iam canceling the Close event such that user is not
| closing app when X button was clicked.
| I tryied to add Environment.Has ShutdownStarted but it not works. When i
| disable e.Cancel = true, windows is closing normally.
| Have any idea how to bite this?
| PK
|
| private void Form1_Closing(o bject sender,
| System.Componen tModel.CancelEv entArgs e)
| {
| this.Visible = false;
| this.activated = false;
| this.WindowStat e = FormWindowState .Minimized;
|
| if (!Environment.H asShutdownStart ed)
| {
| // Cancel the close...
| e.Cancel = true;
| }
| }
|
|

By setting e.Cancel to true, you prevent windows to close the form and as
such the application.
You should set e.Cancel to false is you accept to close.

Willy.

Sep 28 '06 #4
By setting e.Cancel to true, you prevent windows to close the form and as
such the application.
You should set e.Cancel to false is you accept to close.
I dont have to. e.Cancel is false by the default. Anyway
Environment.Has ShutdownStarted isn't true even if iam closing windows. How
do i detect that windows is shutting down in other way...
Sep 28 '06 #5

"PiotrKolodziej " <pi************ *@gmail.comwrot e in message
news:1b******** *************** ***@news.chello .pl...
|By setting e.Cancel to true, you prevent windows to close the form and as
| such the application.
| You should set e.Cancel to false is you accept to close.
| >
|
| I dont have to. e.Cancel is false by the default. Anyway
| Environment.Has ShutdownStarted isn't true even if iam closing windows. How
| do i detect that windows is shutting down in other way...
|
|

This is one of the way's to detect a "system shutdown", another way is to
register a handler for the SystemEvents.Se ssionEnding and/or SessionEnded
events.

However, in the subject line you state "reset of power off", if you mean by
this, pushing the reset or power button, it will depend how the system is
configured what action will follow.
A reset will in general stop the system cold, pushing the power button will
execute whatever was set in the power options (hibernate, standby,
shutdown...).

Willy.
Sep 28 '06 #6
However, in the subject line you state "reset of power off", if you mean
by
this, pushing the reset or power button, it will depend how the system is
configured what action will follow.
A reset will in general stop the system cold, pushing the power button
will
execute whatever was set in the power options (hibernate, standby,
shutdown...).

Willy.
Thank you.
I registred an event that you were talking about.
Sep 29 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

25
3051
by: tnrABC | last post by:
The approximately 100 books below are for sale. Mostly a selection of mathematics (numerical analysis mostly), computing science (graphics, ai, programming techniques, theory, compilers, operating systems, Unix, languages (C, C++, Smalltalk, Java, Pascal, Modula etc.), and a sprinkling of others (e.g. surviving as a consultant, writing resumes, and so on). Most are either new or in as-new condition. Some older ones have begun to attract...
6
2704
by: EW | last post by:
I have a problem when using the python script found here: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/360649 It is a script to remotely shutdown a windows computer. When I use it, the computer shuts down, but doesn't power off like with a regular shutdown. It stays on the "Safe to power off" screen and I have to push the power button to actually power off. Anyone know why this happens with this script? Thanks for any...
24
2605
by: Xah Lee | last post by:
What is Expresiveness in a Computer Language 20050207, Xah Lee. In languages human or computer, there's a notion of expressiveness. English for example, is very expressive in manifestation, witness all the poetry and implications and allusions and connotations and dictions. There are a myriad ways to say one thing, fuzzy and warm and all. But when we look at what things it can say, its power of
1
717
by: Daniel | last post by:
System.IO.StreamWriter Close or Flush method to shut down the computer in such a way that just part of the file is written? or an empty file is written? Also if the Close or Flush is to a streamwriter writing to a network share, is it possible for the network to go down in such a way that the tartet file is only partialy written? or are there some kind of check sums to prevent this.
52
7071
by: onsbomma | last post by:
I want to set and reset the least significant bit of a address (where a pointers points to). I tried this, but it is not correct: #define BIT 0x1 void foo(){ void *p; *p = *p & ~BIT
23
3648
by: Xah Lee | last post by:
The Concepts and Confusions of Pre-fix, In-fix, Post-fix and Fully Functional Notations Xah Lee, 2006-03-15 Let me summarize: The LISP notation, is a functional notation, and is not a so-called pre-fix notation or algebraic notation. Algebraic notations have the concept of operators, meaning, symbols placed around arguments. In algebraic in-fix notation, different
1
1127
by: =?Utf-8?B?Um9i?= | last post by:
My home pc, which is running XP Professional, will not move past the initial screen that shows the Intel Pentium IV emblem. I can't even start in safe mode. What can I do? It was caused by trying to read from a memory card from Sony Ericsson mobile. -- Rob
1
2937
by: tvnaidu | last post by:
Currently I am using power on switch on computer, I would like to use power strip switch to turn on or off computer instead power switch on computer, can I do that?. do I have to setup something in computer control panel ?. I want to controln the computer on/off using power plug switch rather than front panel switch.
0
9453
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10099
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10036
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9904
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8929
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7451
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5481
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2849
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.