
1)ctrl + alt + delt 进程里选程序然后关闭
2)不然 开始-〉运行 打入msconfig 在服务和启动里选不要的程序,
3)再不然就要改注册表了。。。这个觉得有点困难,可以写一个小的shell来做。
4)最后有一个小软件叫做process explorer 是微软的一个小程序,下载以后何以察看现在系统运行中的程序,然后选定一个关掉也很放便,这个程序也只不过1mb左右,对查木马也有一点用。
在线程中,如果要暂停一定的时间,可以使用Thread的Sleep方法,让线程暂停。在微软新的win8API中,已经用Task来实现原来用线程实现的许多功能,同样,Task也有Delay方法,让程序暂停一定的时间。
以下程序利用SystemThreadingTimer让程序每隔间隔的时间执行回调方法:
using System;
using SystemCollectionsGeneric;
using SystemText;
using SystemThreading;
namespace TimerApp{
class Program{
static void Main(string[] args){
ConsoleWriteLine(" Working with Timer type /n");
// Create the delegate for the Timer type
TimerCallback timeCB = new TimerCallback(PrintTime);
// Establish timer settings
Timer t = new Timer(
timeCB, // The TimerCallback delegate type
"Hello From Main", // Any info to pass into the called method (null for no info)
5000, // Amount of time to wait before starting
TimeoutInfinite); //一秒钟调用一次 Interval of time between calls (in milliseconds)
ConsoleWriteLine("Hit key to terminate");
ConsoleReadLine();}
static void PrintTime(object state){
ConsoleWriteLine("Time is: {0}, Param is: {1}",
DateTimeNowToLongTimeString(), stateToString());}
如果把时间间隔1000改成 TimeoutInfinite,这样回调方法PrintTime只会在1秒之后调用一次。
除了Threading下有个Timer类之外,net中还有另一个Timer,就是SystemTimer名称空间下的Timer。此Timer的用法和Threading下的Timer不太相同。
SystemTimersTimer t2 = new SystemTimersTimer(100);
t2Elapsed += t2_Elapsed;
//t1AutoReset = false;
t2Enabled = true;}}
void t2_Elapsed(object sender, SystemTimersElapsedEventArgs e){}
其中AutoReset属性的含义是是否在每次时间间隔到了都触发Elapsed事件还是只触发一次(t1AutoReset = false;)。
解决此类问题的一个小例子(实现在窗体上相隔指定时间显示字幕)
//创建StopNtime类
using System;
using SystemCollectionsGeneric;
using SystemLinq;
using SystemText;
using SystemThreading;
namespace 程序运行暂停器{
class StopNtime{
public StopNtime(){
SystemWindowsFormsControlCheckForIllegalCrossThreadCalls = false;//,跨线程调用控件必加上去 }
private int stopTime = 0;//暂停的时间
ThreadStart myStart;
Thread TheStop;
public readonly object MyLockWord = new object();
public void stopWay(int stopTime){
thisstopTime = stopTime;
myStart = new ThreadStart(this ToStop );
TheStop = new Thread(myStart );
TheStopStart();
private void ToStop(){
lock (MyLockWord){
ThreadSleep(this stopTime );
ThreadCurrentThreadAbort();
//主窗体代码
using System;
using SystemCollectionsGeneric;
using SystemComponentModel;
using SystemData;
using SystemDrawing;
using SystemLinq;
using SystemText;
using SystemWindowsForms;
using SystemThreading ;
using SystemCollections;
namespace 程序运行暂停器{
public partial class Form1 : Form{
public Form1(){
InitializeComponent();}
private void Form1_Load(object sender, EventArgs e){
label1Text = "";
Thread f = new Thread(f1 );
fStart();}
string MyWord = "问题:1+1= \n答案是:2 ";
private void f1(){
StopNtime mmm = new StopNtime();
foreach (char m in MyWord){
lock (mmmMyLockWord ){
label1Text += mToString();
mmmstopWay(300);
//运行结果
可以用以下两种方式
1sleep(n);n是以毫秒为单位的;
2delay(n);n是以毫秒为单位的;
例如延迟一秒是sleep(1)或者是delay(1000);
延时函数,参数 pausetime 为需要暂停的时间,单位是秒
Public Sub Delay(PauseTime As Long)
Dim Start As Single
Start = Timer
Do While Timer < Start + PauseTime
DoEvents
Loop
End Sub
Threadsleep(long millis)和Threadsleep(long millis, int nanos)静态方法强制当前正在执行的线程休眠(暂停执行),以“减慢线程”。
当线程睡眠时,它睡在某个地方,在苏醒之前不会返回到可运行状态。
当睡眠时间到期,则返回到可运行状态。
:
SLEEP是一种函数,作用是延时,程序暂停若干时间,在执行时要抛出一个中断异常,必须对其进行捕获并处理才可以使用这个函数。
参考资料:
以上就是关于如何让程序暂停运行全部的内容,包括:如何让程序暂停运行、如何让C#程序在执行中暂停一段时间、C语言问题:延迟的代码是什么例如暂停一秒后再运行等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)