Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/313.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 用C语言调用定时器_C#_Timer - Fatal编程技术网

C# 用C语言调用定时器

C# 用C语言调用定时器,c#,timer,C#,Timer,我想知道是否有人能提供一些建议。我需要在我的程序中自动化一个过程,当指纹被捕获时,它会通过在向导中调用ShowNext自动转到下一页 public partial class AddFingerprintsPage : Neurotec.Samples.WizardPage ... #region Scanner // Fingerprint Scanner public void timer1_Tick(object sender, EventArgs e)

我想知道是否有人能提供一些建议。我需要在我的程序中自动化一个过程,当指纹被捕获时,它会通过在向导中调用ShowNext自动转到下一页

public partial class AddFingerprintsPage : Neurotec.Samples.WizardPage
...

        #region Scanner // Fingerprint Scanner
        public void timer1_Tick(object sender, EventArgs e)
        {
            Timer timer1 = new Timer();
            timer1.Interval = 1000; 
            timer1.start() // 

              {
                Form2 f2 = new Form2();
                f2.Show(); // Display Form2 which asks user to present finger..
              }
              if (capturing..)
                 { 
                  blah blah capture finger.. 
                  timer1.stop()
                  }

         }

我不知道什么才是最好的选择。我已经尝试过做一个if语句,所以当timer1.stop出现在指纹中时,我会以向导的形式调用它并转到下一页。但是我很确定我没有正确调用它,即使我调用了,我仍然有这个错误“非静态字段、属性方法'NeurotechSamples.AddFingerprintsPage.timer1'需要一个对象”

    public void ShowNext()
    {
        if(Neurotec.Samples.Fingers.AddFingerprintsPage.timer1.stop()) // Not sure what to call here?
        ShowPage(_currentPage + 1, false);
    }

任何帮助都将不胜感激

在AddFingerprints页面上,添加一个静态bool并调用它Stopped,并在计时器停止时将该值设置为true:

  public static bool Stopped = false;


  if (capturing..)
             { 
              blah blah capture finger.. 
              timer1.stop()
              Stopped = true;
              }
然后你可以说:

 public void ShowNext()
{
    if(Neurotec.Samples.Fingers.AddFingerprintsPage.Stopped) 
    {
         ShowPage(_currentPage + 1, false);
    }
}

您遇到的错误是,您需要创建Neurotec.Samples.Fingers.AddFingerprintsPage的新实例,以引用timer1,因为它不是静态的。

为什么首先需要计时器?如果我理解正确,您只需打开表单,然后对“用户已给出其指纹”事件作出反应。或者我这里遗漏了什么?请解释一下你想用定时器做什么。正如所写的,你的计时器代码毫无意义。是的,本质上我只需要打开表单,然后在事件发生时调用下一页。我想在几秒钟后开始这个过程,因为屏幕上会显示说明。谢谢。。我是否需要ifNeurotec.Samples.Fingers.add指纹spage.Stopped=true?您不需要在if语句中显式地说==true,因为它总是检查条件是否为true。即使像ifNeurotec.Samples.Fingers.AddFingerprintsPage.Stopped==false这样的语句也表示检查是否返回false,如果返回false,则返回true,如果不返回false。
 public void ShowNext()
{
    if(Neurotec.Samples.Fingers.AddFingerprintsPage.Stopped) 
    {
         ShowPage(_currentPage + 1, false);
    }
}