Windows Worker Service times out
Hello. Everytime I want to start my Worker Service I get the message that it doesnt reacted in time and I dont know why I get this error. because everytime I run the exe noremally the whole thing works.
Program.cs
Worker.cs
80 Replies
what is the error that you are getting, exactly
Your
ExecuteAsync
runs sync until the first await Task.Delay
. I guess serviceCode.systemcode()
does some lengthy operation and because it is run sync you get that messageYes it's doing an infinite loop with a check
So I just have to switch the logger message with the myservercode...
Right?
oh, you want to run it as a Windows Service?
Yes
you did not call
AddWindowsService
Oh hm
But I've the same thing with
Sec
I've that:
And it's also not working
well, i can guarantee that it will not work without UseWindowsService
Okay
And if I do that it should work then right?
no, that does not matter
Hm
Ms isn't doing it differently
https://learn.microsoft.com/en-us/dotnet/core/extensions/workers
Worker Services - .NET
Learn how to implement a custom IHostedService and use existing implementations in C#. Discover various worker implementations, templates, and service patterns.
this should just work
Okay i'll try as soon as I'm in work
Doesn't work
is there anything in the event logs related to the application
Oh missing .dll file
But now "Could not resolve CoreCLR path."
what was the missing dll and how did you fix it
Just added the .dll file into the folder
how did you configure the service
like, what is the path it's trying to run
No. You block the
ExecuteAsync
method with the serviceCode.systemcode()
and that causes the not responding service.
As a rough method change it to await Task.Run( () => serviceCode.systemcode() );
C:\Users<Name>\Desktop\servs
But you should be aware that you cannot stop that task, because you did not code that method to be stopable
you pointed it at the exe file?
Like that?
yes
:thonkThinkWatWutWhatDerpConfused: then I need to look how I can stop it then
well, the "Could not resolve CoreCLR path." means it is not even running right now
i think the easiest way to fix it is to use self-contained
running in a container will make the whole program useless
Because it checks for a USB Device
it is not a container
oh
it just means that it puts the .NET runtime next to the exe
so it does not have to look for your installation
which, for whatever reason, it can't do
<SelfContained>true</SelfContained>
in your project file in the PropertyGroup
then when you build you have to copy the entire build folder to wherever the service is running from
do not just copy a handful of files, you cannot forget anything or the whole thing doesn't workAnd I cant build it with -p:PublishReadyToRun=true into a single .exe
i mean if you are doing
dotnet publish
-p:PublishSingleFile=true
then instead of the
<SelfContained>
business
i would do
dotnet publish -p:PublishSelfContained=true -p:PublishSingleFile=true ...
yeah
that is fineWhat is SelfContained doing?
reflectronic
it just means that it puts the .NET runtime next to the exe
Quoted by
<@384454726512672768> from #Windows Worker Service times out (click here)
React with ❌ to remove this embed.
Ah
Now it's started
But it does nothing :shyyDead:. But prob. I need to download the driver for the usb device sec
@reflectronic but now it doesn't run the redacted code
how do you know it is not running it
before you changed what
yes, you can't just run a windows service as a console application
if you want to run it as a console application you need to delete AddWindowsService and rebuild it
Ik but it doesn't even call the one class
Can I DM you the top of the code?
i mean. yes, if you do AddWindowsService, and then run it as a console application, it will do nothing
this is expected
It does nothing in generall
It just starts not more
what do you mean by "in general"
Sec I'll dm you the redacted things
i still don't understand what is different now
if you delete AddWindowsService, and run it as a console application, it will work exactly as it did before
it does not matter what the code is doing
Yes it also would do the things it should do. But as soon as I run it as Service it doesn't work
the fact that it isn't working as a windows service is a different matter
Yes
it looks like your service uses some UI features
Do you mean the Console logs?
i mean, there is MessageBox
this means it needs to run as an interactive service
Oh yea but that's not so important
The most important thing is to get the base working :gx_laugh:
the fact that you are not running it as an interactive service may be the reason it is not working
Hm sec
Then shouldn't jt lognerrors?
you just need to check the check box i think
in the service properties
i mean. who knows what it does right now. maybe it just hangs
Yes but still not working :/
do you see message boxes now
Possible
Nope nothing
if you put a MessageBox at the very beginning do you see it
Sec
Nothing
Could it be that windows can't find the driver from the usb device?
Come on, interactive services are obsolete since years
Interactive Services - Win32 apps
Typically, services are console applications that are designed to run unattended without a graphical user interface (GUI).
The only thing it should do is lock the user
It does not matter what it "only" should do - you simply can not have interaction from a service to the desktop. period.
Yes
If you want an interaction you need two instances/applications and one has to run in the context of the current user which will communicate with the service and do the interaction with the user
Yes
Unknown User•10mo ago
Message Not Public
Sign In & Join Server To View
Both I tried
Why?
But could it be that it needs user32.dll?
Unknown User•10mo ago
Message Not Public
Sign In & Join Server To View
Because it needs to interact with user specific things like lock the user and more
I'd do in private but not in public
Unknown User•10mo ago
Message Not Public
Sign In & Join Server To View
If I share it to someone in private and the person publishes the code without my consent, then I know then who I can sue then
Can I send you the files in private?
Unknown User•10mo ago
Message Not Public
Sign In & Join Server To View
All my code has the CC-BY-NC-ND 4.0 International License
Unknown User•10mo ago
Message Not Public
Sign In & Join Server To View