 |
|
 |
when i run this application this error is raised
Cross-thread operation not valid: Control 'labelNow' accessed from a thread other than the thread it was created on.
in
public void Application_Tick()
{
while (!(this.labelNow.Text.ToString().Equals(this.dateTimePicker.Value.ToString())))
{
this.labelNow.Text = System.DateTime.Now.ToString();
}
this.Computer_Shutdown();
}
and i don't have experience in threading and i don't know how can i solve it...
thanks,
|
|
|
|
 |
|
 |
Hi,
you better use System.Windows.Forms.Timer instead of threads. In the TICK event handler you could easly access any Windows.Forms element.
And by the way: don't use the shown way of comparing clocks. Use e.g. DateTime.CompareTo(), that would work even better.
kind regards
|
|
|
|
 |
|
 |
Hello.
I'm a new here, and I have learned C# for a short time. The "Timer Computer Shutdown" is good done, can you tell me how can make the program running without .NET Framework.
modified on Thursday, October 23, 2008 4:03 AM
|
|
|
|
 |
|
 |
Hello...
i have a problem...
if i am running a process in windows like copy data or download, and i want this application are stop until the process windows finished. if windows process finished(like copy data or download), so this application will execute. so i have to read process in task manager. can you help me to read the process in task manager??? how i get the source?
|
|
|
|
 |
|
 |
Hi,
you want to read the process list of your system, is that right? I recently wrote a project like the one shown and added a watch to a special process - when ended the system will shut down. I can post it to you.
Here is the access to the process list:
foreach (System.Diagnostics.Process proc in System.Diagnostics.Process.GetProcesses())
Kind regards
|
|
|
|
 |
|
 |
Hi,
When I run this application CPU usage is about 90 percent. Do you have any suggest to decrease CPU percentge?
|
|
|
|
 |
|
 |
If you use timer the program will not use cpu %90. The solution is timer!!
|
|
|
|
 |
|
|
 |
|
 |
Hey I want to learn about this if possible I want to shutdown my computer from a timer/calander I have read the article but to be honest I dont even know where to put the code to start with Woulbe over the moon if someone could take the time to help me get started.
Thanks Josh
|
|
|
|
 |
|
 |
using System;
using System.Runtime.InteropServices;
[DllImport("user32.dll")]
public static extern void LockWorkStation();
class Lock
{
static void Main(String[] args)
{
LockWorkStation();
}
}
|
|
|
|
 |
|
|
 |
|
|
 |
|
 |
hii steve...
nice work.is there any possibility to perform these actions on other systems connected using LAN.... if there plz let me kno...
|
|
|
|
 |
|
 |
nice program - i have only tried the shutdown once on my xp box and it did not work - it closed the application and VS and then ... nothing else happened??
then i tried a reboot and that worked fine
i need this to work on the following OS's 98SE, ME, NT4, WIN2000, WINXP
do you think this will work?
|
|
|
|
 |
|
 |
Hi frends!
I havn't tried out this program yet but i was wondering, does c# provide functions that could possibly close running applications properly (particularly internet connection since im using a dial-up) before shutting down? If so could someone please give me a boost on this one. Thanx so much!
Kampai!!!
|
|
|
|
 |
|
 |
I think you should add a Thread Sleep in your
Application_Thick :
this.labelNow.Text = System.DateTime.Now.ToString();
System.Threading.Thread.Sleep(500) ; // e.g 500 msec
or your Application will dominate the CPU. (check CPU utilization in the Task Manager).
Regards
Erv
ebret
|
|
|
|
 |
|
 |
Hi
Is there a way of setting your monitor to standby, or even turning it off?
|
|
|
|
 |
|
 |
hi!
excellent program, very helpful
i have it working on winxp no problem
when i try on my win 2k machine, i get the error below
win2k sp4, .net 1.1
any help appreciated
thanks!!
----------------------------------------
Unable to find an entry point named FormatMessageA in DLL user32.dll.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.EntryPointNotFoundException: Unable to find an entry point named FormatMessageA in DLL user32.dll.
Source Error:
Line 49: private void Button1_Click(object sender, System.EventArgs e)
Line 50: {
Line 51: Org.Mentalis.Utilities.WindowsController.ExitWindows(RestartOptions.Reboot, false);
Line 52: }
Line 53: }
Stack Trace:
[EntryPointNotFoundException: Unable to find an entry point named FormatMessageA in DLL user32.dll.]
Org.Mentalis.Utilities.WindowsController.FormatMessage(Int32 dwFlags, IntPtr lpSource, Int32 dwMessageId, Int32 dwLanguageId, StringBuilder lpBuffer, Int32 nSize, Int32 Arguments) +0
Org.Mentalis.Utilities.WindowsController.FormatError(Int32 number) +54
Org.Mentalis.Utilities.WindowsController.ExitWindows(Int32 how, Boolean force) +71
Org.Mentalis.Utilities.WindowsController.ExitWindows(RestartOptions how, Boolean force) +59
reboot._default.Button1_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\808multimedia.com\reboot\default.aspx.cs:51
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1292
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.2032; ASP.NET Version:1.1.4322.2032
|
|
|
|
 |
|
 |
Hi Steve,
The application is simply superb. But, it doesn't work when I have my computer locked. (I haven't yet confirmed whether the application works after screen saver auto locks the PC).
Willstay.
|
|
|
|
 |
|
 |
Has anyone found a way to get this to work when the computer is locked?
|
|
|
|
 |
|
 |
I didn't research much into this matter. Instead I found resources for the same using windows API and code in MS Visual C++. It is working great for me.
|
|
|
|
 |
|
 |
Is there a possibility to wakeup the PC with C#?
|
|
|
|
 |
|
 |
Yes, there is. It's possibly to wake up your pc by a WOL-script (Wake On Lan). As the name says, it only works on a LAN network.
I've made a GUI around a basic WOL script, and called my program G-WOL.
You can download the executable (with readme.txt) here.
|
|
|
|
 |
|
 |
maybe try a more orthodox way using DEVCON from M$ (downloadable)
http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q311272
or even triggering the shutdown command in XP
using
System.Diagnostics.Process p = System.Diagnostics.Process.Start(...
This seems a bit virus-like to be good for your machine's OS, sorry.
craig soens-hughes
dotnet @ orange.net - happy to help.
|
|
|
|
 |
|
 |
Nice work I must say but when I was trying to make brute shutdown on WinXP, .NET ver1.1, OS crashed with blue screen. I presume kill process is killing some very important process, maybe dot net framework process and crash OS, that is rebooting after that blue screen. Any idea?
Preky
|
|
|
|
 |