调用方法无限期 [英] Calling method indefinitely

查看:171
本文介绍了调用方法无限期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用在c#wpf项目中使用c ++ / cli创建的包含正常c代码的.dll。
c代码的函数需要永久调用。这个函数最终在c命令行应用程序的main函数中的无限循环中调用。

I want to use a .dll created with c++/cli that includes normal c code in an c# wpf project. A function of the c code needs permanent calling. This function was orginally called in an endless loop in the main function of a c command-line-application.

如何从wpf c#项目永久调用函数,而不会干扰其他应用程序?我想这应该很容易,但新的到wpf和相当新的.Net。

How do I call a function permanently from a wpf c# project without interfering with the rest of the application? I guess that should be pretty easy but Im new to wpf and fairly new to .Net.

推荐答案

using System.Threading;

Thread t = new Thread(()=>{
while(true)
{
//call your method here...
Thread.Sleep(500); //optional if you want a pause between calls.
}
});
t.IsBackground = true;
t.Start();

这篇关于调用方法无限期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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