zoukankan      html  css  js  c++  java
  • C# 多线程传递多个参数

    http://www.cnblogs.com/lvdongjie/p/5416883.html

    3. 方式三:采用lambda表达式

    对于lambda表达式不熟悉的可以查看微软MSDN上的说明文档。此处假设你熟悉。因为在大多数使用委托的时候我们一般也可以用lambda表达式的。

     View Code
    using System;
     using System.Threading;
      
     namespace ThreadWithParameters
     {
         class Program
         {
             static void Main(string[] args)
             {
                 string hello = "hello world";
      
                 //如果写成Thread thread = new Thread(ThreadMainWithParameters(hello));这种形式,编译时就会报错
                 Thread thread = new Thread(() => ThreadMainWithParameters(hello));
                 thread.Start();
      
                 Console.Read();
             }
      
             static void ThreadMainWithParameters(string str)
             {
                  Console.WriteLine("Running in a thread,received: {0}", str);
             }
         }
     }


  • 相关阅读:
    Serverless 动态博客开发趟“坑”记
    tsv与csv文件
    zypper
    source、sh、./三种执行方式对脚本变量的影响
    linux nm
    ldconfig
    cpio
    License简介
    rpm之spec文件
    使用rpmbuild制作rpm包
  • 原文地址:https://www.cnblogs.com/LuoEast/p/7753831.html
Copyright © 2011-2022 走看看