I have a Console Application that every x minutes makes an API call and, based off the response, control some IoT switches.
I need this to run 24/24 on a windows machine. I figured out that running it as a console application the risk is that the timer could broke over time.
How can I convert this app to a windows service without rewriting it from zero? I also implemented some console-logging stuff, so I'd like to run the application as console, and have a service to generate the timer elapsed events, if it's possible.
Ps: The timer interval is something between 2 to 5 minutes, and the program run only during day (it checks the photovoltaic production and the API request limit is 300 per day, so I check only when sun is actually out)
C# service from console application
507 Views Asked by leolamarra At
1
There are 1 best solutions below
Related Questions in C#
- Passing arguments to main in C using Eclipse
- kernel module does not print packet info
- error C2016 (C requires that a struct or union has at least one member) and structs typedefs
- Drawing with ncurses, sockets and fork
- How to catch delay-import dll errors (missing dll or symbol) in MinGW(-w64)?
- Configured TTL for A record(s) backing CNAME records
- Allocating memory for pointers inside structures in functions
- Finding articulation point of undirected graph by DFS
- C first fgets() is being skipped while the second runs
- C std library don't appear to be linked in object file
- gcc static library compilation
- How to do a case-insensitive string comparison?
- C programming: Create and write 2D array of files as function
- How to read a file then store to array and then print?
- Function timeouts in C and thread
Related Questions in .NET-CORE
- Repository manager receives the wrong connection string in .net core
- How can I overwrite the localization strings in a library
- Custom type resolution
- How to enable log to console Cosmos Client SDK requests
- Issue with Entity Framework Core: .Include() and .AsNoTracking() not displaying expected related entities
- Using Python CDK to bundle dotnet 8 code to AWS Lambda function
- How to make Visual Studio 2022 project launch Windows Terminal instead of PowerShell?
- Custom Metrics stop saving in App Insight after one hour
- How to send select input data for form submission?
- When I use built-in DockerFile in Visual Studio, I see no errors, but when I try to create image and container using terminal I get an error
- Failure to Execute the DBCommand: SQLite Err. 1 - C# / .NET / Entity Framework Core
- KeyCloak Handshake causing timeout
- problemas con los CORS en .net core 7 y angular 15
- Access Registed Scoped Services and Transient Services using GetService()
- .NET Core DB vs JSON model design
Related Questions in SERVICE
- Why does Angular ^17 have problems with my modules, services, etc
- Problem with Android App background service stoping
- How to use interceptors with services in nestjs
- Exchange data between a Windows service and an application
- Unable to resolve service name to its IP inside kubernetes cluster
- Self Hosted Agent service startup getting failed on VM restart
- Linux service stops logging
- Disable/Enable OSB proxy service via WLST
- Write rows on destination even when an error occurs?
- paho mqtt java cannot reconnect after a long time machine sleep
- IServiceCollectionConfigurator' does not contain a definition for 'UsingRabbitMq'
- "setOngoing(true)" Notification dismissed by user
- How to run powershell command in OnStart of ServiceBase Class in C#?
- Is there any way to globally override Android's back button click?
- Terraform Azure Provider: Authenticating using a Service Principal with a Client Certificate
Related Questions in CONSOLE-APPLICATION
- C# Console app do not exit until CTRL+C pressed without while loop
- Time usage saved from a process is not properly stored/shown
- Is it safe to integrate with SharePoint online API through a console application which is hosted on local VM
- How to publish .NET Core console application with particular profile?
- Protected .pyd not working with debug mode in c# sharp console application
- .NET 8 Console App DI Error 'Unable to resolve service for type 'Microsoft.Extensions.Logging.ILoggerFactory'
- Why is my cursor in a random far-away place in Visual Studio Debug Console
- I'm trying to write a simple program that picks a random number between 1 and 10 and gives the user to guess it
- Accessing DI elements like IConfiguration from within nested class in a Core console app
- Is it possible to listen for console input from a C# Windows Application?
- Win32 Console Application Unexpectedly Terminates with Code 58
- Conway's Game of Life: unexpected behavior
- .NET Core console application crashes on debug
- How to tell a program to clear the console in python
- Create docker Img from .NET Core (Console APP) that creates output file is not creating files with docker run
Related Questions in SYSTEM.TIMERS.TIMER
- CS0123 No overload for 'method' matches delegate System.Timers.ElapsedEventHandler
- Reducing delay between System.Timers.TImer calls
- timer configuration not working in console application c#
- C# how to get a object back from a system.timer and use it in the calling tread
- Why would my timer does not dynamically display the file size?
- EF: PROBLEM WITH DBCONTEXT ACCESS FROM 2 DIFFERENT System.Timers.Timer
- C# service from console application
- C# .NET6.0 System.Timers: When elapsed event is fired the eventhandler is executed multiple times
- In ASP.NET web application, in which method do I implement a timer that calls a function every 5 minutes? There's no main() could it be in PageLoad?
- System.Timers.Timer not firing at the interval set
- How to send a message to a Discord Channel every X seconds?
- How to periodically check for status using an asynchronous method and support timeout?
- How to use System.Timers.Timer properly inside a class
- Timeout for System.Timers.Timer and exception throwing
- Is the System.Timers in C# precise enough when I want to execute some code exactly every 30ms?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
If the application is well-written, then the application logic is separated from the user-interface (CLI in this case) and you could simply implement only the UI in your Windows app and reuse the same classes that you were using in the initial project.
If the prerequisite above is not met, that is, the application logic is mixed up with the user interface handler, then you will need to refactor the initial project so you will end up with a project where the app logic is separated from the user interface handler.