What is the best way to create background application?
-
write it as service. But why do you need such app. Such app can be easly considered malicious programs
Thanks. I need it to backup files in my system and to sync between some computer in my office.
-
Thanks. I need it to backup files in my system and to sync between some computer in my office.
Then i suggest writing it so that it will move to system tray
-
If i want to create an application without any console and without any form that for example: 1. every 20 hours send an email 2. backup some folder or doing anything without the user interaction. 3. Will write a log to a file. 4. will run a process if some event occur. I know that i can make a form application but then i need to mark the form with 0% Opacity. That will take a lot of memory for the process. What is the best way?
-
If i want to create an application without any console and without any form that for example: 1. every 20 hours send an email 2. backup some folder or doing anything without the user interaction. 3. Will write a log to a file. 4. will run a process if some event occur. I know that i can make a form application but then i need to mark the form with 0% Opacity. That will take a lot of memory for the process. What is the best way?
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
-
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.
-
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
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
-
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
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
//MessageBox.Show(bobo(1, 2).ToString(), "", MessageBoxButtons.OK, MessageBoxIcon.Information);
Thread.Sleep(1000);
Main();
//Application.Run(new Form1(bobo(1, 2)));
}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
-
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
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
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
//MessageBox.Show(bobo(1, 2).ToString(), "", MessageBoxButtons.OK, MessageBoxIcon.Information);
bobo(1, 2);
Thread.Sleep(1000);
Main();
//Application.Run(new Form1(bobo(1, 2)));
}private static int bobo(int a, int b) { return (a + b); } }
}
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
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
//MessageBox.Show(bobo(1, 2).ToString(), "", MessageBoxButtons.OK, MessageBoxIcon.Information);
bobo(1, 2);
Thread.Sleep(1000);
Main();
//Application.Run(new Form1(bobo(1, 2)));
}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());.
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, 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());.
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);
orMessageBox
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()) { // System.Threading.Thread.Sleep(1 \* 1000); // MessageBox.Show("new", "", MessageBoxButtons.OK, MessageBoxIcon.Information); goto begin; } } private static bool testLoop() { while (baba != 101) { //Thread.Sleep(1 \* 100); 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 AssemblerBad = knowing 2 much