473,326 Members | 2,128 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

"C#" Back from Application.Run to place where was is called

6
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
Jul 16 '08 #1
10 1863
Plater
7,872 Expert 4TB
So make a dummy Form that does the .ShowDialog() code and never actually shows itself.?
Jul 16 '08 #2
wael20
6
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
Jul 16 '08 #3
Plater
7,872 Expert 4TB
What are you trying to do? The structure isn't too clear.
You can do this, if it helps:
Expand|Select|Wrap|Line Numbers
  1. TestForm tm = new TestForm;
  2. Application.Run(tm);
  3.  
Jul 16 '08 #4
wael20
6
Just for example:
[PHP]
public class ProgramTEST
{
public ProgramTEST()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(fals e);
Application.Run(new MyApplicationContext(new string[] {})); // -->This bolcks the course of the application.
}

public ControlTester buttonTester;

public void Test()
{
buttonTester = new ControlTester("_okButton", "myForm");

buttonTester.FireEvent("Click");
}
}[/PHP]
Jul 17 '08 #5
Plater
7,872 Expert 4TB
I don't know what's going on in your Test() function, but the rest looks fine?
Jul 17 '08 #6
wael20
6
It is just example, a GUI will opened and than will clicked on OK button automatically
Jul 17 '08 #7
Plater
7,872 Expert 4TB
So why not have the code that "clicks" the button automatically happen in the gui, like in the form_load() event handler?
Jul 17 '08 #8
wael20
6
I cannot change anything on the GUI Software, It is Just example, that i click on this button, the problem is:

On this following line, my program stops:.

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

or, when you write:

ProgramTEST MyTest = new ProgramTEST(); // here my program stops, tell i close the GUI!!!But i need the GUI!
MyTest.Test();
Jul 18 '08 #9
Plater
7,872 Expert 4TB
HAve you tried making a new thread?
Jul 18 '08 #10
wael20
6
I started my GUI in Thread, but i cannot debug it!

Expand|Select|Wrap|Line Numbers
  1. public ProgramTEST()
  2. {
  3.           ApplicationTestStart _applicationTestStart = new ApplicationTestStart();
  4.           ThreadStart ts2 = new ThreadStart(_applicationTestStart.Run);
  5.           Thread t1 = new Thread(ts2);
  6.           t1.Start();
  7. }
--------------------------------------------------------------------------
Expand|Select|Wrap|Line Numbers
  1. public ApplicationTestStart()
  2. {
  3. }
  4. public void Run()
  5. {
  6.           Application.EnableVisualStyles();
  7.           Application.SetCompatibleTextRenderingDefault(false);
  8.           Application.Run(new BootApplicationContext(new string[] { }));
  9. }
  10.  
do you know, how i can use "BeginInvoke" make it work?
Jul 18 '08 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

33
by: Steven Bethard | last post by:
I feel like this has probably been answered before, but I couldn't find something quite like it in the archives. Feel free to point me somewhere if you know where this has already been answered. ...
8
by: Lian | last post by:
Hi all, It is a newbie's question about html tag "img". The attributes "title" and "alt" for "img" seems having the same function. So what is the main difference between them? Can i use them at...
4
by: Patrick | last post by:
I'm writing a winforms database application in C#. I've come across a lot of stuff lately about "N-Tier" architecture. Can anyone give me a simple explanation of N-Tier? The descriptions that...
14
by: MuZZy | last post by:
Hi, Lately i've been (and still am) fixing some memory leaks problems in the project i just took over when i got this new job. Among the other issues i've noticed that for localy created objects...
7
by: charliewest | last post by:
Using .Net CF, i have created a 2 dimension ArrayList, and "binded" this list to a ComboBox control using the "DataSource" property. I have set the DisplaySource and ValueMember properties as well....
10
by: Flare | last post by:
Hi I just read and experimented with normal .net GUI apps and deployed them with notouch deployment strategie as smartclients. Is it just me, or i this an very neglected topic? For me it...
7
by: relient | last post by:
Question: Why can't you access a private inherited field from a base class in a derived class? I have a *theory* of how this works, of which, I'm not completely sure of but makes logical sense to...
9
by: DJ Tuneman | last post by:
I've noticed that if I enable the "Application Framework" in the project for a Windows app, there's a bug when the programs load and I didn't even notice it until lately. If you click the "Show...
0
by: U S Contractors Offering Service A Non-profit | last post by:
" I saw your report " Tom Cruise " I liked it Look at this one if you will..." Inbox U S Contractors Offering Service A Non-profit More options 3:50 pm (9 minutes ago) " I saw your report "...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.