Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/287.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# 如何使应用程序运行多个进程,每个进程使用单独的XML设置文件?_C#_Winforms - Fatal编程技术网

C# 如何使应用程序运行多个进程,每个进程使用单独的XML设置文件?

C# 如何使应用程序运行多个进程,每个进程使用单独的XML设置文件?,c#,winforms,C#,Winforms,我举了一个有条件的例子。 有: -具有设置的文件(文件“类似”): - .. \ 01\setting\fold\u 1\settings\u 1.xml .. \ 01\setting\fold\u 2\settings\u 2.xml .. \ 01\setting\fold\u 3\settings\u 3.xml -数据文件(例如(文件“数据”): .. \ 01\data\fol\u data\u 1\fol\u data\u 1.txt .. \ 01\data\fol\u dat

我举了一个有条件的例子。
有:
-具有设置的文件(文件“类似”):
- .. \ 01\setting\fold\u 1\settings\u 1.xml
.. \ 01\setting\fold\u 2\settings\u 2.xml
.. \ 01\setting\fold\u 3\settings\u 3.xml
-数据文件(例如(文件“数据”):
.. \ 01\data\fol\u data\u 1\fol\u data\u 1.txt
.. \ 01\data\fol\u data\u 2\fol\u data\u 2.txt
.. \ 01\data\fol\u data\u 3\fol\u data\u 3.txt

“设置”文件显示在树状图中。 将焦点移动到树时,所有设置都会显示在表单字段中,具体取决于文件。 该示例中的设置数量通常是可接受的。 事实上,该示例使用了“文件数据”设置“数据”(textBox4)。 在每个“settings_N.xml”中,都有相应“Data”文件的路径

情景

  • 用户。在树中选择一个或多个“类似”文件

    通过将复选框证书选中为“true”进行选择

  • 用户。单击“运行”按钮(按钮3)
  • 程序。在每个“数据”文件的“tabControl”中创建一个单独的选项卡;(在本例中,不使用“tabControl”)

  • 程序。为每个文件“数据”创建DateTables表

  • 程序为每个“数据”文件创建日期网格
  • 解析“数据”文件中的数据
  • 程序。登录到DateTable
  • 程序。放置在数据网格中
  • 对于所有选定的“Nystroka”文件,必须同时执行第4-7项。 在本例中,“运行”按钮(button3)仅为一个“数据”文件执行脚本

    我怀疑这应该通过“多线程”(Thread)来实现,但我不知道如何实现

    或者还有其他方法吗

    问题

  • 如何实现这个场景
  • 如何组织课程
  • Form1.cs
    代码-

    项目-



    我会说使用后台工作人员

    这里有一个很好的例子链接,如果需要,我会自己提供一个例子。

    编辑:

    这是你的一个小例子

    private void MethodForWorker()
    {
        BackgroundWorker worker = new BackgroundWorker();
        // This is where we create the event that will run on the background, not blocking the main thread
        worker.DoWork += this.Worker_DoWork;
        // This is where we create the event that will run after the backgroun as finished doing its work, this is not necessary per say, only if you need for it to run something after the background work is done
        worker.RunWorkerCompleted += this.Worker_RunWorkerCompleted;
        // To start the background work
        worker.RunWorkerAsync();
    }
    
    private void Worker_DoWork(object sender, DoWorkEventArgs e)
    {
        // This is where you put the code that will run on the background
        // Remenber, to send stuff to the main thread you must use the invoke
        this.Invoke(new Action(() =>
        {
            // Code of what you need to pass to the main thread, for example to use a MessageBox or to update a label ? up to you if you need to do stuff on the main thread
        }));
    }
    
    private void Worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
    {
        // This is where you put the code that will run after the Worker_DoWork has finnish doing all is job
    }