|
you can't make an application without a window.
but you can hide it.
you can make a DLL and hook it windows explorer, like a service or something.
but don't ask me how to do it, because i never tried
Bad = knowing 2 much
|
|
|
|
|
Natural_Demon wrote: you can't make an application without a window.
That is only expection for service. They don't have any window.
|
|
|
|
|
Your sig says it all - you are quite wrong. A windows/web service does not cannot have a form.
This is lousy advice, although admitting you have no idea at least puts it in context. Please be a little more careful about what advice you give. If you had been the first responder and the asker was a newbie then you may have damaged a potential developer.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
eh, i remember i asked the same question when i played with MFC c++ 5,6 years ago.
it's impossible for an normal application to operate without a form/cmd.
than as solution, i said, you can write a DLL and hooked it the windows explorer, be it as service or something else, like a virus.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using System.Threading;
namespace nowindow_application
{
static class Program
{
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Thread.Sleep(1000);
Main();
}
private static int bobo(int a, int b)
{
return (a + b);
}
}
}
this application wil not not produce an executable file using visual studio 2008
//MessageBox.Show(bobo(1, 2).ToString(), "", MessageBoxButtons.OK, MessageBoxIcon.Information);
uncomment this file and you have a executable file in your bin folder.
so you can't build a application without a CMD or form layout.
i dind't spread any false hope or something, i asked this question before.
Bad = knowing 2 much
|
|
|
|
|
or try to compile this
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using System.Threading;
namespace nowindow_application
{
static class Program
{
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
bobo(1, 2);
Thread.Sleep(1000);
Main();
}
private static int bobo(int a, int b)
{
return (a + b);
}
}
}
Bad = knowing 2 much
|
|
|
|
|
Hi,
What's your point here? Apart from the recursive call to Main there is nothing that would prevent your example from running to completion.
When a program is compiled as a console application then a window, the console, is always created. Counter intuitively a windows application only has a message loop and window if the programmer writes the appropriate code, usually
Application.Run(new Form1());.<br />
A simple windowless windows application does not show in the taskbar but will be present in Task Manager's process list.
static void Main() {
System.IO.File.AppendAllText(
"log.txt",
"NoWindow started at " + System.DateTime.Now.ToString() + System.Environment.NewLine);
System.Threading.Thread.Sleep(20 * 1000);
System.IO.File.AppendAllText(
"log.txt",
"and ended at " + System.DateTime.Now.ToString() + System.Environment.NewLine);
}
Alan.
|
|
|
|
|
hi, i have been playing with you code.
i tried with threading and other methods.
creating endless/limited loops.
again ....
whitout System.Threading.Thread.Sleep(20 * 1000); or
MessageBox
you code want compile, wel it doesn't produce an executable.
i have achieved 99% cpu usage on a intel 9450.
i think this is a very lousy methode off programming.
to get something valueble on this methode of programming.
static void Main()
{
begin:
if (!testLoop())
{
goto begin;
}
}
private static bool testLoop()
{
while (baba != 101)
{
baba++;
}
baba = 0;
return false;
}
this code comsumes 25% cpu usages and is self sustainable.
but it doesn't produce an executable.
but if you uncomment System.Threading.Thread.Sleep(1 * 1000);
it wil compile but terribly remove the realtime feeling.
it's like imitating the Assembler
Bad = knowing 2 much
|
|
|
|
|
Hello!
Everthing works, but he don´t open myTimer_Tick!!!
open takes the value from the textbox, then * 1000 = 5sec!
public Form1()<br />
{<br />
InitializeComponent(); <br />
}<br />
<br />
void myTimer_Tick(object sender, EventArgs e)<br />
{<br />
System.Diagnostics.Process.Start("winword"); <br />
}
void Listen()<br />
{<br />
<br />
<br />
while (true)<br />
{<br />
try<br />
{<br />
data = new byte[1024];<br />
received = networkStream.Read(data, 0, data.Length);<br />
if (received == 0)<br />
break;<br />
<br />
string get = Encoding.ASCII.GetString(data, 0, received);<br />
var send = get.ToByteArray();<br />
networkStream.Write(send, 0, send.Length);<br />
<br />
if (get.Contains("open_ever_x_sec"))<br />
{ <br />
string[] get_Split2 = get.Split('~');<br />
int open = Convert.ToInt32(get_Split2[1]);<br />
timer1.Tick += new EventHandler(myTimer_Tick);<br />
timer1.Interval = open * 1000;
timer1.Enabled = true; <br />
}<br />
|
|
|
|
|
are you sure that this condition is true
if (get.Contains("open_ever_x_sec"))
put a break point in there and see if it get called or not. If it does then check that is Tick event attached with timer1 and what is the value of open
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKQUFK[M`UKs*$GwU#QDXBER@CBN%
R0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
-----------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
yes it get called!
And open takes the correct value!
He doesn´t open myTimer_tick!!!!
|
|
|
|
|
It suppose to get called, btw write following line after InitializeComponents()
timer1.Tick += new EventHandler(myTimer_Tick); and remove from while loop.
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKQUFK[M`UKs*$GwU#QDXBER@CBN%
R0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
-----------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
|
try adding
timer1.Start();
check if VS didn't already assign event handler
If that doesn't work, try this:
Timer time1 = nre Timer();
time1.Tick += new EventHandler(myTimer_Tick);
time1.Interval = 2 * 1000;
time1.Enabled = true;
modified on Saturday, August 22, 2009 6:38 AM
|
|
|
|
|
doesn´t work!
nre Timer ;awaited!!!
I have tried the code in a new windows form application i have put this code into button click:
timer1.Tick += new EventHandler(myTimer_Tick);
timer1.Interval = 10000; // Millisekunden
timer1.Enabled = true;
and that above the Button_klick
void myTimer_Tick(object sender, EventArgs e)
{
mciSendString("set CDAudio door open", null, 127, (IntPtr)0);
}
And it doesn´t work!
Can somebody try it in a new windows form application and when it works can he send me the full code!!! Please
|
|
|
|
|
void myTimer_Tick(object sender, EventArgs e)
{
MessageBox.Show("1");
}
void listen()
{
Timer time1 = new Timer();
time1.Tick += new EventHandler(myTimer_Tick);
time1.Interval = 1 * 1000;
time1.Enabled = true;
time1.Start();
}
I Have tried this at windows form app and it worked. However i coudn't do with console app. I noticed that console app timer doesn't work, so i found alternative solution:
http://www.mycsharpcorner.com/post.aspx?postid=31[^]
|
|
|
|
|
Thanks, alright your code works in a new Windows Form Application but with not!
I have tried nearly everthing but it doesn´t work!!!
this code also works, but not by Server and Client:
for(int i =0;i<int.MaxValue;i++)
{
System.Diagnostics.Process.Create('winword'); // Word
System.Threading.Thread.Sleep(10000); // 10 Seconds
}
I don´t why but it doesn´t work!!!
Thank you at all!
|
|
|
|
|
PC17 wrote: but with not!
I assume you meant witg your app NOT.
Did you create project as service?
|
|
|
|
|
Hi,
It works but it doesn't!
I have questions about the Listen method. Does it block at
received = networkStream.Read(data, 0, data.Length);<br />
until data arrives? What happens next, that is, does it loop around and block again waiting for more data?
Alan.
|
|
|
|
|
Timer works in diffrent Thread, as soon Timer.Enabled set to true, it will send event every time an event Ticked and it doesn't matter how occupied is the main thread
|
|
|
|
|
Hi,
The code fragment shows that he is using System.Forms.Timer which raises events on the UI thread.
Alan.
|
|
|
|
|
I Think you are on to something.
Timer time1 = new Timer();
time1.Tick += new EventHandler(myTimer_Tick);
time1.Interval = 1 * 1000;
time1.Enabled = true;
time1.Start();
while (true)
{
}
This above code doesn't fire anything, so i think he needs to create timer in another class, while that class is created in a diffrent thread using System.Threading
|
|
|
|
|
It doesn´t work!
I have tired it with a new server and client and it doesn´t work here is the Server and Client Source code with timer:
http://ul.to/7xbgwn[^]
if by somebody works, please post me!
|
|
|
|
|
Hi,
Finally you post code showing the root cause of the problem. The Listen method is running on a secondary thread and the System.Windows.Forms.Timer is designed to operate on the UI thread only.
You may
1) Wrap the timer manipulation code in a method and use this.Invoke and a method delegate to force the code to run on the UI thread.
OR
2) Change the timer to either System.Threading.Timer or System.Timer.
Option 2 would be the cleaner solution.
Alan.
|
|
|
|
|
I tried the the second solution, but it doesn´t work!
Maybe i habe made something wrong can you send me the code how do you mean!
Please
|
|
|
|
|
Hi,
Your most common response to any suggestion is "it doesn't work" without any backup information.
Please post a relevant code sample with details of the test you performed and the result of the test.
Alan.
|
|
|
|