如何在上一个过程之后启动另一个进程 [英] how to start another process after previous process

查看:67
本文介绍了如何在上一个过程之后启动另一个进程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的任务中,我需要在病毒扫描完成后进行屏幕捕获,但由于文件和文件夹的大小可能会有所不同,因此扫描时间也会如何克服这一点,我想得到如果
已经完成扫描所需的时间,那么只需要截取屏幕截图。

In my task, I need to take screen capture after the virus scan has completed but it is quite hectic because the file and folder size may vary so the scanning time will too how to overcome this and I want to get the time taken for scanning if that is completed then only it has to take screenshot.

推荐答案

您可以使用秒表捕获总扫描时间,并在完成后使用Complete()方法执行其他操作。

You can use Stopwatch to capture the total scan time and do other things in the Complete() method after it's done.

尝试以下示例:

    public delegate void Entrust();

    private void Form1_Load(object sender, EventArgs e)
    {
        Entrust callback = new Entrust(Timer1Complete);
        Thread th = new Thread(ProcessTimer1);
        th.IsBackground = true;
        th.Start(callback);
    }

    private void ProcessTimer1(object obj)
    {
        Stopwatch watch = new Stopwatch();
        // start timing
        watch.Start();
        // simulate virus scan
        for (int i = 1; i < int.MaxValue; i++) { }

        Entrust callback = obj as Entrust;
        callback();
        //stop timing
        watch.Stop();
        label1.Invoke(new Action(() => { label3.Text = watch.Elapsed.ToString() + "s"; }));
    }

    private static void Timer1Complete()
    {
        // start another process
        Process.Start("cmd.exe");
    }

问候,

Stanly


这篇关于如何在上一个过程之后启动另一个进程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆