日期:2014-05-17  浏览次数:21148 次

C#中怎么结束一个已经触发了的事件
在wince中有个上传图片事件,现在有可能无线网络有问题,图片上传需要很久。想做个计时器,如果超过5秒,就报错。

用线程来做以上功能,遇到了多线程带参数的问题,网上搜了一大把,不能用,求解

public void Route_StartCamareEvent(string name)
       {
            //网上说可以用ParameterizedThreadStart,但是wince下没有这个
            //求这边到底怎么传参数比较好
            threadwcf =new Thread(new ThreadStart(wcfrun);

            threadtime = new Thread(new ThreadStart(timerun));
            threadwcf.Start(name);//这边报错,貌似不可以这么用的
            threadtime.Start();
        }

        private void timerun()
        {
            for (var i = 3000; i > 0; i--)
            {
                if (i < 100)
                {
                    this.statusBar1.Text = Status.wlanTimeOut;
                    threadwcf.Abort();
                    FTPClient ft = new FTPClient();
                    ft.CopyFiles(Path.PicPath, Path.TemporaryPath);
                    threadtime.Abort();
                    return;
                }
                Thread.Sleep(2);
            }
        }

        public void wcfrun(string name)
        {
            picCount.Add(name);
            threadwcf.Abort();
            threadtime.Abort();
        }

------解决方案--------------------
大哥!你把Start 转到定义 看一下参数描述 


        //
        // 摘要:
        //     使操作系统将当前实例的状态更改为 System.Threading.ThreadState.Running,并选择提供