博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
C#简单的多线程
阅读量:6880 次
发布时间:2019-06-27

本文共 682 字,大约阅读时间需要 2 分钟。

这个日志还是挺有用的,有什么想不起来的过来翻翻挺好,以后多多记录。C#简单的多线程以前用过,但是现在感觉好陌生。。。今天又查了查,赶紧记录一下。

private void LayoutRoot_SizeChanged(object sender, SizeChangedEventArgs e){    //使用object传递参数    Thread loadmap = new Thread(new ParameterizedThreadStart(LoadMapAsync));    loadmap.Start(17);    //不需要参数的异步方法    Thread loadmap2 = new Thread(new ThreadStart(LoadMapAsync2));    loadmap.Start();}//使用object传递过来后自己再转换类型void LoadMapAsync(object param){    int level = (int)param;    while (MapServerHelper.GetStartPos(level) != null)        LoadMap(MapServerHelper.GetStartPos(level));}//直接执行代码void LoadMapAsync2(){    while (MapServerHelper.GetStartPos(0) != null)        LoadMap(MapServerHelper.GetStartPos(0));}

转载地址:http://hrubl.baihongyu.com/

你可能感兴趣的文章