在asp.net web里面调用C# windowForm里面的生成dll,里面的timer不起作用了。
如题,我该怎么才能实现过一段时间调用方法呢。该怎么写。哪位好心人给点代码啊。。可以用的话立即给分。。
如果可以不用timer 的话该怎么写,能实现就行。 --------------------编程问答-------------------- 过一段时间不用timer
我不会 --------------------编程问答-------------------- 自己怎么写的
Timers.Timer myTimer = new System.Timers.Timer();
myTimer.Elapsed += new System.Timers.ElapsedEventHandler(OnTimedEvent);
myTimer.Interval = 1000;
myTimer.Enabled = true;
private static void OnTimedEvent(object source, System.Timers.ElapsedEventArgs e)
{
}
还有windows 任务 --------------------编程问答--------------------
//建timer
public System.Timers.Timer timer = new System.Timers.Timer();
//单击录像按钮
public void Lx(string strg, string strg23 )
{
try
{
i = 0;
al.Clear();
//初始化timer
timer.Interval = 10;
timer.Elapsed += new System.Timers.ElapsedEventHandler(TimerEvent);
strg1 = strg23;
DirectoryInfo DInfo = new DirectoryInfo(strg1);
if (!DInfo.Exists)
{
DInfo.Create();
}
string Mycursor = "显示光标";
if (Mycursor == "显示光标")
{
CheckCursor = true;
}
else
{
CheckCursor = false;
}
//记时开始
timer.Start();
ButtonStartStatus();
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
}
//停止录像
public void LxStop(string strg30,string savepath,string deleteimg)
{
try
{
contextMenuStrip1.Items[0].Enabled = true;
this.ShowInTaskbar = true;
menuStrip1.Visible = true;
statusStrip1.Visible = true;
this.StartPosition = FormStartPosition.CenterScreen;
toolStripButton1.Enabled = true;
toolStripButton3.Enabled = false;
//停止timer
timer.Stop();
//保存视频
aviSaveAs(savepath);
ButtonStopStatus();
DeleteFolder(deleteimg);
MessageBox.Show("视频保存成功!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
//timer事件
private void TimerEvent(object sender, System.Timers.ElapsedEventArgs e)
{
try
{
Bitmap a;
if (CheckCursor)
{
a = CaptureDesktop();
}
else
{
a = CaptureNoCursor();
}
string picpath = strg1 + "\\" + i + ".bmp";
if (i == 0)
{
SWidth = a.Width;
SHeight = a.Height;
}
a.Save(picpath);
al.Add(picpath);
i++;
RegisterHotKey(Handle, 83, KeyModifiers.Shift, Keys.E);
}
catch
{ } }
上面是我的代码,,timer事件在windowForm中运行可以,生成DLL 在web里面调用开始录制的的方法,发现进不去timer事件。。
不知道是怎么回事。 --------------------编程问答-------------------- 没有人回答吗 --------------------编程问答-------------------- private void TimerEvent(object sender, System.Timers.ElapsedEventArgs e)
{
try
{
Bitmap a;
if (CheckCursor)
{
a = CaptureDesktop();
}
else
{
a = CaptureNoCursor();
}
string picpath = strg1 + "\\" + i + ".bmp";
if (i == 0)
{
SWidth = a.Width;
SHeight = a.Height;
}
a.Save(picpath);
al.Add(picpath);
i++;
RegisterHotKey(Handle, 83, KeyModifiers.Shift, Keys.E);
}
catch
{ } }
把异常写出来看看吧
web限制还是蛮厉害的,不能调用winform很大一部分是winform程序的问题,不是web。
你想写的这种程序还是很难写的,注册表方面,还有IE数字证书方面,需要好多资料。
web只对在开始->运行->直接能打开的程序没有太多限制,这种程序大多数有注册表,很多也是微软的自己产品,你调用记事本,netMeeting都不会有问题。 --------------------编程问答-------------------- --------------------编程问答-------------------- 就是我在 web里面调用这个方法的时候
//单击录像按钮
public void Lx(string strg, string strg23 )
{}
里面有个timer.start()
这个里面的
//timer事件 进不去
private void TimerEvent(object sender, System.Timers.ElapsedEventArgs e)
我调试了 进不去。 --------------------编程问答-------------------- 有没有谁以前弄过了的 --------------------编程问答-------------------- 在web里timer.Elapsed事件里的变量必须是静态变量,用实例对象的变量就没用,我也很郁闷,在winform里可以但是到web上又不行了 --------------------编程问答-------------------- 网页里 你可以用Cache实现 Timer,Cache被移除时可以执行回调执行服务端事件 在回调里再重复设定Cache就类似Timer了
如果仅仅是在客户端网页实现 参考 javascript 的 window.setTimeout 事件 --------------------编程问答-------------------- 神贴,居然10年的帖子还没结?
补充:.NET技术 , ASP.NET