如何在C#Windows应用程序中使用线程调用函数. [英] how to call function using thread in C# windows application.

查看:49
本文介绍了如何在C#Windows应用程序中使用线程调用函数.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到问题了..上一次我使用这段代码时,它运行得很好.

hi i am having problem .. last time i was using this piece of code and it was wroking fine.

Thread thread = new Thread(new ThreadStart(TMDBDownload));
thread.Start();


但是现在我使用它并没有带我进入功能"TMDBDownload",当我跨步进入该功能时,我在该功能中添加了一些断点..并未进入内部.上次我在Windows XP 32位操作系统上制作了应用程序.
但是现在我正在使用Windows7 64bit,并且我在窗体上使用了选项卡控件,并放置了一些文本框,标签和按钮等.当我单击按钮时,有一个功能使我自己拥有名称"TMDBDownload"的线程没有我认为该功能.一定有什么不对劲或我不知道的东西.

我期待着您的尽快答复.

最好,
Ans.


but now i use this it doesn''t bring me into the function"TMDBDownload" i put some break point in the function when i step into its just get over it .. doesn''t go inside. last time i made application on windows xp 32 bit operating system.. i puted some controls on the from...

but right now i am using Windows7 64bit and i used tab Control on the form and putted some textboxes and labels and buttons etc. when i click the button there is a function i made that by myself having name "TMDBDownload" thread doesn''t call that function i think. there must be something wrong or what i don''t know..

i am looking forward for your reply as soon as possible.

Best,
Ans.

推荐答案

这两行没有什么问题(除了过多的new ThreadStart不会造成损害).问题出在这两个之外.

首先,让我为您提供一个使用线程包装器处理线程的好方法.请查看我过去的答案:
如何将ref参数传递给线程 [ ^ ],
启动后更改线程(生产者)的参数 [ ^ ].

我也可以带给您正确的主意.

—SA
There is nothing wrong in these two lines (except excessive new ThreadStart which does not hurt). The problem is somewhere outside those two.

First of, all, let me offer you the good way of working with threads by using a thread wrapper. Please see my past answers:
How to pass ref parameter to the thread[^],
change paramters of thread (producer) after it started[^].

I could also bring you to the right idea.

—SA


这篇关于如何在C#Windows应用程序中使用线程调用函数.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆