c#写一个实时监控的程序。 老大,可不可以给点资料,有关服务程序和多线呈怎么写?多多地谢啊啊!!xupc(寻巢鸟) ,我跟你混啊。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 给你一个线程操作的例子,关于服务程序,就随便把窗口隐藏一下算了,省事,嘿嘿 private void StartBtn_OnClick(object sender, System.EventArgs e) { this.LastTime =DateTime.Now; System.Threading.ThreadStart threadStart =new System.Threading.ThreadStart(Thread); System.Threading.Thread thread =new System.Threading.Thread(threadStart); thread.IsBackground =true; thread.Start(); this.notifyIcon1.Text ="数据发送驻留程序-已启动"; this.button1.Enabled =false; } /// <summary> /// 线程中检测时间 /// </summary> private void Thread() { while(true) { System.TimeSpan ts =new TimeSpan(0,0,int.Parse(this.DBFTime),0,0); DateTime DBFDateTime =this.LastTime+ts; DateTime TXTDateTime =DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd")+" "+this.TXTTime); DateTime NowDateTime =DateTime.Now; if (NowDateTime.ToString()==DBFDateTime.ToString()) { this.InserDBFData(); this.UpLoadFile(); this.InsertFromExcel(); // this.Up701Data(); this.LastTime =DBFDateTime; } /* if (NowDateTime.ToString() ==TXTDateTime.ToString()) { this.UpLoadFile();//其他调用方法 this.InsertFromExcel();//其他调用方法 this.InserDBFData();//其他调用方法 } */ System.Threading.Thread.Sleep(200); } } 程序搞好了。但是。。我是用一个窗体,然后在上面放了一个按钮,点击按钮,运行线程,隐掉窗体,每隔10分钟测一下数据库。但是,关闭程序的时候必须要通过任务管理器。。很郁闷,如何能把它做成象qq那样可以最小化到右下角的呢??另一个小问题,我的win2kprofessional,发现一个非常讨厌的问题ctrl+alt+del,再按任务管理器,出现一个没有最大化,最小化和关闭按钮的窗口,也没有程序和性能的选项卡,只能显示进程,每次都要用alt+f4才能关闭,非常可恶,该怎么办呢? 用trayicon就ok,看一下msdn范例,很简单的双击任务管理器中间,呵呵 “双击任务栏中间”----多多地谢iamcj朋友 线程优化,如何能让界面不太卡。 avicap32.dll中的那个方法可以获取其填充在PictureBox中的图像数据? 如何取出Form中所有的ListBox? 制作一个SQL连接数据库的代码 这个功能我该怎么做? 为什么要读研究生? c# webform调用excel后,无法关闭excel进程,怎么解决? 关于excel关闭的问题 象素和cm,inch之间怎么换算? 请问如何把下列的 C 语言代码转化为 C# 代码, 谢谢了, 小问题!巨郁闷!!! 我遇到简单一个问题,希望大家给我解决。
private void StartBtn_OnClick(object sender, System.EventArgs e)
{
this.LastTime =DateTime.Now;
System.Threading.ThreadStart threadStart =new System.Threading.ThreadStart(Thread);
System.Threading.Thread thread =new System.Threading.Thread(threadStart);
thread.IsBackground =true;
thread.Start();
this.notifyIcon1.Text ="数据发送驻留程序-已启动";
this.button1.Enabled =false; }
/// <summary>
/// 线程中检测时间
/// </summary>
private void Thread()
{
while(true)
{
System.TimeSpan ts =new TimeSpan(0,0,int.Parse(this.DBFTime),0,0);
DateTime DBFDateTime =this.LastTime+ts;
DateTime TXTDateTime =DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd")+" "+this.TXTTime);
DateTime NowDateTime =DateTime.Now;
if (NowDateTime.ToString()==DBFDateTime.ToString())
{
this.InserDBFData();
this.UpLoadFile();
this.InsertFromExcel();
// this.Up701Data();
this.LastTime =DBFDateTime;
}
/*
if (NowDateTime.ToString() ==TXTDateTime.ToString())
{
this.UpLoadFile();//其他调用方法
this.InsertFromExcel();//其他调用方法
this.InserDBFData();//其他调用方法
}
*/
System.Threading.Thread.Sleep(200);
}
}
另一个小问题,我的win2kprofessional,发现一个非常讨厌的问题
ctrl+alt+del,再按任务管理器,出现一个没有最大化,最小化和关闭按钮的窗口,也没有程序和性能的选项卡,只能显示进程,每次都要用alt+f4才能关闭,非常可恶,该怎么办呢?