" C#"从Application.Run返回到被调用的地方 [英] "C#" Back from Application.Run to place where was is called

查看:82
本文介绍了" C#"从Application.Run返回到被调用的地方的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,


C#!!!

如何从Application.Run返回到被叫的地方?

所以我不能用这种方式:


MyMainForm myForm = new MyMainForm();

myForm.ShowDialog() ;


谢谢

Hello,

C# !!!
How can i back from Application.Run to place where was is called?

or, what should i do, when i must to use Application.Run( new MyMainForm() ) to run my application?
so i can′t use this way:

MyMainForm myForm = new MyMainForm();
myForm.ShowDialog();

Thanks

推荐答案

因此,创建一个执行.ShowDialog()代码的虚拟表单,从不实际显示自己。 ?
So make a dummy Form that does the .ShowDialog() code and never actually shows itself.?


我需要GUI,我开始使用NUnitforms进行测试......


所以...

如何从Application.Run返回到被调用的地方? (用NUnitforms测试它)


或者,我该怎么办,何时必须使用Application.Run(new MyMainForm())来运行我的应用程序?

所以我不能用这种方式:


MyMainForm myForm = new MyMainForm();

myForm.ShowDialog();


因为我的应用程序使用了Backgroundworker。


我试过这样,但是我无法调试它:

.....

ApplicationTestStart _applicationTestStart = new ApplicationTestStart();

ThreadStart ts = new ThreadStart(_applicationTestStart.Run);

线程t1 =新线程(ts);

t1.Start();

------------------------------------------ --------------------------------------

公共类ApplicationTestStart

{

public ApplicationTestStart()

{

}


public void Run()

{

Application.EnableVisualStyles();

Application.SetCompatibleTextRenderingDefault(fals e);

Application.Run(new MyApplicationContext(new string [] {}));

}

}


谢谢
I need the GUI, that i started, to test it with NUnitforms...

so...
How can i back from Application.Run to place where was is called? (to test it with NUnitforms)

or, what should i do, when i must to use Application.Run( new MyMainForm() ) to run my application?
so i can′t use this way:

MyMainForm myForm = new MyMainForm();
myForm.ShowDialog();

because my application use Backgroundworker.

I tried it like this, but i couldn''t debug it:
.....
ApplicationTestStart _applicationTestStart = new ApplicationTestStart();
ThreadStart ts = new ThreadStart(_applicationTestStart.Run);
Thread t1 = new Thread(ts);
t1.Start();
--------------------------------------------------------------------------------
public class ApplicationTestStart
{
public ApplicationTestStart()
{
}

public void Run()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(fals e);
Application.Run(new MyApplicationContext(new string[] {}));
}
}

Thanks


你想做什么?结构不太清楚。

如果有帮助,你可以这样做:
What are you trying to do? The structure isn''t too clear.
You can do this, if it helps:
展开 | < span class =codeLinkonclick =selectAll(this);>选择 | Wrap | 行号


这篇关于&QUOT; C#&QUOT;从Application.Run返回到被调用的地方的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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