For a big project I am going to be making a C# Program which does a variety of things that a user specified, there is a user interface, that will be accessible from a System Icon, and ever present logo on the screen.
I want the program to run at start up and be there in the background until shutdown, such as many common antivirus/malware programs out there today.
I also want the program to be installed in order to run.
I know there's alot here. I know how to get the program to run at startup (startup folder), but like with AntiVirus I want it to always be there, and not just be in the startup folder...
I originally thought this was a service, but I am not too sure now, and I am having a nightmare getting my head around it all. What is the best way to do this ? The GUI is a must.
Would appreciate any and all answers, tips and suggestions.
Thanks in advance.
C# language support is an optional install from the Marketplace. You can install it from within VS Code by searching for 'C#' in the Extensions view ( Ctrl+Shift+X) or if you already have a project with C# files, VS Code will prompt you to install the extension as soon as you open a C# file. Video Tutorial on Getting Started with C# in VS Code ...
The dotnet build command builds the project and its dependencies into a set of binaries. The binaries include the project's code in Intermediate Language (IL) files with a .dll extension. Depending on the project type and settings, other files may be included, such as:
Like all managed code, .NET Core applications are executed by a host. The host is responsible for starting the runtime (including components like the JIT and garbage collector) and invoking managed entry points. Hosting the .NET Core runtime is an advanced scenario and,...
.NET is a free, cross-platform, open source developer platform for building many different types of applications. With .NET, you can use multiple languages, editors, and libraries to build for web, mobile, desktop, games, and IoT.
Anti-virus programs and similar system tray applications sometimes or often have 2 components. There's a service that starts with the system, and a separate system tray application in the startup folder that interacts with the server to provider user access to service functionality when a user is logged in to a desktop. One of the questions you'll have to answer is whether you want anything running when nobody is logged in. If so, you'll want a service component. If not, you can maybe put everything in one application that creates a system tray icon. To put an icon in the system tray from a .NET application, refer to http://www.developer.com/net/net/article.php/3336751/C-Tip-Placing-Your-C-Application-in-the-System-Tray.htm
If I understand/recall correctly, there's a .NET component designed for putting icons in the system tray.
Here's the sample I mentioned above.
This code is located in the TaskbarUtility, and all events throughout the application create new Forms through here.
I'm not sure if this is the "right" way to do something like this, and I don't intend to be thread-jacking, but I figured I might as well share. :)
List<CommonFormBase> activeWindows = new List<CommonFormBase>();
public void LaunchApplication(ApplicationWindowType formTypeToLaunch)
{
CommonFormBase tempForm;
switch (formTypeToLaunch)
{
//implement code to create a new form here
}
activeWindows.Add(tempForm);
tempForm.Name = "UniqueName:" + System.DateTime.Now;
tempForm.FormClosed += new FormClosedEventHandler(tempForm_FormClosed);
tempForm.Show();
}
void tempForm_FormClosed(object sender, FormClosedEventArgs e)
{
if (sender is CommonFormBase)
{
//Get the index of the selected form
int index = -1;
for (int i = 0; i <= this.activeWindows.Count - 1; i++)
{
if (this.activeWindows[i].Name == ((Form)sender).Name)
index = i;
}
//Remove the selected form from the list
if (index >= 0)
activeWindows.RemoveAt(index);
//Close the TaskbarUtility if no remaining windows
// and user choose to exit when none remain
if (this.activeWindows.Count == 0 && CloseWhenNoWindowsRemain)
{
this.Close();
}
}
}
Hope that makes sense.
The assumption is that not all users want the app to run all the time, so this will close the entire program when they enable the option.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With