• 大小: 0.05M
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2020-12-26
  • 语言: C#
  • 标签: 进程  定时器  

资源简介

c#自动启动进程并自动加载关闭winform前的值-定时器操作

两个要点:一个是程序入口函数,一个是程序关闭前的处理以及System.Threading.Timer的简单用法

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Windows.Forms;

namespace ProcessAutoStart
{
    public partial class Form1 : Form
    {
        public int curIndex = 1;
        public Form1(string[] args)
        {
            InitializeComponent();
            if(args.Length>1)this.textBox1.Text=args[0];
            System.Threading.Timer timer = new System.Threading.Timer(new TimerCallback(AutoStart) curIndex 1000 1000);
            timer.Change(1000 1000);
        }

        public void AutoStart(object test) 
        {
            System.Diagnostics.Process curPro = System.Diagnostics.Pr

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2012-12-20 14:02  ProcessAutoStart\
     目录           0  2012-12-20 14:02  ProcessAutoStart\ProcessAutoStart\
     目录           0  2012-12-20 14:02  ProcessAutoStart\ProcessAutoStart\bin\
     目录           0  2012-12-20 14:38  ProcessAutoStart\ProcessAutoStart\bin\Debug\
     文件        9216  2012-12-20 14:38  ProcessAutoStart\ProcessAutoStart\bin\Debug\ProcessAutoStart.exe
     文件       22016  2012-12-20 14:38  ProcessAutoStart\ProcessAutoStart\bin\Debug\ProcessAutoStart.pdb
     文件       22472  2012-12-20 14:02  ProcessAutoStart\ProcessAutoStart\bin\Debug\ProcessAutoStart.vshost.exe
     文件         490  2010-03-17 22:39  ProcessAutoStart\ProcessAutoStart\bin\Debug\ProcessAutoStart.vshost.exe.manifest
     文件        1438  2012-12-20 14:38  ProcessAutoStart\ProcessAutoStart\Form1.cs
     文件        2986  2012-12-20 14:34  ProcessAutoStart\ProcessAutoStart\Form1.Designer.cs
     文件        5817  2012-12-20 14:34  ProcessAutoStart\ProcessAutoStart\Form1.resx
     目录           0  2012-12-20 14:02  ProcessAutoStart\ProcessAutoStart\obj\
     目录           0  2012-12-20 14:38  ProcessAutoStart\ProcessAutoStart\obj\Debug\
     文件         863  2012-12-20 14:02  ProcessAutoStart\ProcessAutoStart\obj\Debug\DesignTimeResolveAssemblyReferences.cache
     文件        6833  2012-12-20 14:02  ProcessAutoStart\ProcessAutoStart\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
     文件         632  2012-12-20 14:38  ProcessAutoStart\ProcessAutoStart\obj\Debug\ProcessAutoStart.csproj.FileListAbsolute.txt
     文件         975  2012-12-20 14:38  ProcessAutoStart\ProcessAutoStart\obj\Debug\ProcessAutoStart.csproj.GenerateResource.Cache
     文件        9216  2012-12-20 14:38  ProcessAutoStart\ProcessAutoStart\obj\Debug\ProcessAutoStart.exe
     文件         180  2012-12-20 14:38  ProcessAutoStart\ProcessAutoStart\obj\Debug\ProcessAutoStart.Form1.resources
     文件       22016  2012-12-20 14:38  ProcessAutoStart\ProcessAutoStart\obj\Debug\ProcessAutoStart.pdb
     文件         180  2012-12-20 14:38  ProcessAutoStart\ProcessAutoStart\obj\Debug\ProcessAutoStart.Properties.Resources.resources
     目录           0  2012-12-20 14:02  ProcessAutoStart\ProcessAutoStart\obj\Debug\TempPE\
     文件        3745  2012-12-20 14:03  ProcessAutoStart\ProcessAutoStart\ProcessAutoStart.csproj
     文件         921  2012-12-20 14:02  ProcessAutoStart\ProcessAutoStart\ProcessAutoStart.sln
     文件       20480  2012-12-20 14:39  ProcessAutoStart\ProcessAutoStart\ProcessAutoStart.v11.suo
     文件         557  2012-12-20 14:12  ProcessAutoStart\ProcessAutoStart\Program.cs
     目录           0  2012-12-20 14:02  ProcessAutoStart\ProcessAutoStart\Properties\
     文件        1370  2012-12-20 14:02  ProcessAutoStart\ProcessAutoStart\Properties\AssemblyInfo.cs
     文件        2884  2012-12-20 14:02  ProcessAutoStart\ProcessAutoStart\Properties\Resources.Designer.cs
     文件        5612  2012-12-20 14:02  ProcessAutoStart\ProcessAutoStart\Properties\Resources.resx
     文件        1103  2012-12-20 14:02  ProcessAutoStart\ProcessAutoStart\Properties\Settings.Designer.cs
............此处省略1个文件信息

评论

共有 条评论