|
I writing some application that does not hold any GUI class.
I need my application to stay a live until i "kill" it from the task manager.
My problem is that i don't know how to keep it a live ...
When i have some GUI application - i have some class that derived from the class Form - and in the mail i do something like this ( in the main )
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new someClassThatDerivedForm());
this keep the application run until the ui class "someClassThatDerivedForm" will be close.
but as i said - in my application i don't have any ui - and i don't want to create some dummy class that Derived from the Form class.
Thanks for any help.
|
|
|
|
|
What you are describing is a Service application. Service applications don't have UIs. You can opt for them to start when the computer does or to start manually. Once started they typically run until asked to stop running. Service Applications are derived from the ServiceBase [^]class and can be started, stopped, and restarted though a ServiceController [^](or though the services onsole under "Services" in the Control Panel of your computer).
|
|
|
|
|
Sorry, but i dont want to define service.
I just want to make some class that will run forever - until it will kill by the task manager.
When you run some appliction by create some class in the Main you will exit the application when the class will done - and i need some way to continue run my application forever - that meen that i need to run some "forever" method in the constructor of the class that will not stop at all.
In the UI we do it by polling messages.
But i want to do it without using UI class.
Is there is some way to do it ?
|
|
|
|
|
Yanshof wrote: When you run some appliction by create some class in the Main you will exit the application when the class will done
Incorrect, it will run until the Main method terminates. Because you are using Application.Run() in the Main method, it will run until the GUI component (the form derived object you supply to the run method) is closed (e.g. it receives the WM_CLOSE event)
Yanshof wrote: and i need some way to continue run my application forever
Infinite loops - That is effectively what the message pump is (the bit that keeps your GUI application running)
Yanshof wrote: that meen that i need to run some "forever" method in the constructor of the class that will not stop at all.
forever... That sounds a lot like a for statement could be useful...
Yanshof wrote: But i want to do it without using UI class.
Yes, the correct way, as you've already been told, is to make the application a Windows Service.
Yanshof wrote: Is there is some way to do it ?
If you want to do it correctly (which you don't seem to, but I'll say it anyway) is to make your application a Windows Service.
Out of curiosity, why don't you want to make it a Windows Service?
|
|
|
|
|
Hi,
not sure what the problem is.
[STAThread]
static void Main() {
for ( ; ; ) {
try {
} finally {}
}
}
takes a long time to execute.
I try not to call this an eternal loop since that is hard to prove,
and available energy is finite
|
|
|
|
|
Luc Pattyn wrote: available energy is finite
Move closer to the LHC.
|
|
|
|
|
There still is a small matter of a non-functional transformer that will cost a few dimes and several months to fix.
|
|
|
|
|
I have created a form with a height of 28 with no title bar or border. Yet when the form is run the height jumps to about 32 pixels. Even adding code that changes the form's height to 28 isn't working.
I'm currently using Microsoft Visual C# 2008 express. The issue should be repeatable by making a new form. Setting the following properties:
ControlBox: false
FormBorderStyle: none
Size: 400,20
and then running. Is there a system minimum height requirement for forms that I don't know about, or am I just missing some obvious setting?
|
|
|
|
|
Yeah, you're missing the height of the title bar that isn't there. Even if the title bar is turned off, it still contributes to the minimum height of the form.
|
|
|
|
|
That makes sense. Now if I can just find a way to make the title bar smaller it seems my troubles will be over. Though the only thing I've found so far is System.Windows.Forms.SystemInformation.CaptionHeight, and that's read only.
Perhaps I'll have to abandon the form and try a different method. Thanks Dave.
|
|
|
|
|
It just occured to me that it may be because the ControlBox is still turned on. Set it to False and you might be able to get what you want. (I don't have time to try it right now...)
|
|
|
|
|
The control box was set to false, I said that in my original post. Unless you know of a different way to turn it off other than the forms ControlBox property. I spent a good couple of hours trying different things to no avail. I gave up on it.
|
|
|
|
|
did you try setting the Form.Text to an empty string?
|
|
|
|
|
Yes I did, sorry if I didn't mention that in the first post.
|
|
|
|
|
No problem.
I tried it myself, setting lots of things off and/or minimal, to no avail, minimum size is 124*36
on my system, whatever borderstyle I choose.
Best explanation so far is Windows wants to prevent you from making a Form ungrabable.
|
|
|
|
|
good day everyone
so i created a class called stuff, like this
public class stuff
{
public string str1;
public long l1;
public DateTime d1;
public DateTime d2;
public string str2;
public LocalFiles()
{}
}
i want to create an array of this class like : stuff[] S = new stuff[100]
then when i want to insert a value in it (like S[1].str1 = "ds" i get an error, what am i doing wrong?
thanks in advance
|
|
|
|
|
mirko86 wrote: i get an error
and what error are you getting?
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Individuality is fine, as long as we do it together - F. Burns
|
|
|
|
|
i get the "Object reference not set to an instance of an object." exception
|
|
|
|
|
When you create your array, you're only creating 100 places for references to your "stuff" objects. The problem is that those references don't point anywhere until you instantiate an object in each of those array slots.
S[1] = new stuff();
|
|
|
|
|
i dont think thats gonna solve my problem though
this is exactly what i want to do:
stuff[] LC = new Stuff[somehashtable.Values.Count];
int y=0;
foreach (string values in somehashtable.Values)
{
LC[y].str1=
}
i want to copy all the values of the hashtable to my "stuff" Array
|
|
|
|
|
You have to do it this way:
public class Stuff
{
public int a = 0;
public int b = 1;
public string c = "string stuff";
public Stuff()
{
}
}
Stuff[] m_stuff = new Stuff[10];
public CreateStuff()
{
for (int i = 1; i < 10; i++)
{
m_stuff[i] = new Stuff();
}
}
At that point, you can access your stuff.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
ok problem solved!
thanks a lot guys you really helped me
modified on Friday, December 19, 2008 5:31 PM
|
|
|
|
|
Hey guys I am hoping someone can help. What I want to do is send an e-mail at 7:00 AM once a day. I know how to send an e-mail, and i thought i could do this using either a timer or a thread. This is also going to be a windows service in case that makes a difference.
Thanks,
Travis Combs
|
|
|
|
|
|
Will Timer1 control be solution for you?
If yes then enable Timer1 and check current time if is 7:00 AM and in that case execute code which send email.
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
|
|
|
|