与任务调度程序或任务管理器相比,窗口服务如何在内部工作? [英] How window services work internally compared to task scheduler or task manager?

查看:86
本文介绍了与任务调度程序或任务管理器相比,窗口服务如何在内部工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是一名从事网络应用程序工作的.net开发人员,过去几个月我开始研究Windows应用程序,一个应用程序需要每天中午12点运行,所以我在google的帮助下编写了一个Web服务,它正在运行很好。



但我只是想知道Windows服务是如何工作的。

我读了很多帖子而没有人回答我的问题。所以用我自己的话说出来。



根据我在网络服务中的理解,我使用计时器创建一个调度程序,它运行24小时,并在定时器执行必要的代码条件得到满足。



在调度程序中,我配置一个调度程序,在满足时间条件时运行一个应用程序(以前的服务)。



现在我的问题:



1.关于RAM使用情况?



我知道服务使用RAM。但考虑到我的代码是否很重,我们考虑10mb。 Ther fore.exe文件大约为10mb或更多。因此,当服务启动时,它会在24小时内使用10mb的RAM,或者只是创建服务中的调度程序,这将非常小,然后在满足时间时加载服务代码?



考虑调度程序如何工作。我认为会有一个触发器在遇到时间时触发并触发触发器将执行.exe文件通常让我称之为服务(但它是一个应用程序)。所以这里服务代码与调度程序分离,因此只有调度程序运行并将服务代码加载到RAM中。



我是对的吗?

调度程序是否也会在24小时内检查所有时间?



2.如果我有一个安装程序的2个服务。现在将安装2个服务。但是我想知道两个服务是否都是10mb,这两个服务的大小是20mb。并且当两个服务开始运行时,每个服务的大小都是10mb(考虑到它将导致相关服务代码)或者每个20mb(考虑到它)将使用两个服务代码,因为它们在同一个exe中。



希望获得一些有价值的答案。



提前致谢。



我的尝试:



我刚刚在c sharp中实现了windows服务,它运行正常。

I am a .net developer working in web applications and from past few months I started working on windows applications and one application need to run every day at 12 noon so I wrote a web service with the help of google and it is working fine.

But I am just wondering how windows services work.
I read lot of posts and not one have answered my question.So coming forward in my own words.

According to my understanding in web service I create a scheduler using timer that runs all 24 hours and will execute the necessary code when the timer condition is met.

In scheduler I configure a scheduler that runs an application(which is a service in previous case) when the time condition is met.

Now my questions:

1. Regarding RAM usage?

I know services utilizes RAM. But considering if my code is heavy like lets consider 10mb. Ther fore .exe file will be around 10mb or more. So when service starts does it utilizes 10mb of RAM all 24 hours or it will just create just scheduler in service which will be pretty small and then loads service code when the time is met?

Considering scheduler how does it work. I think there will be a trigger that is fired when time is met and fired trigger will execute .exe file generically let me call it a service(but it is a application). So here the service code is separated from scheduler so only scheduler runs and loads service code into RAM.

Am I right?
Does scheduler also runs all 24 hours checking time?

2. If in case I have 2 services with one installer. Now there will be 2 servises installed. But I would like to know if both services is of 10mb each which makes 20 mb .exe size and when both services starts running does there sizes be of 10 mb each(considering it will lode relative service code) or 20 mb each(considering it will lode both service codes because they are in same exe).

Hoping for some valuable answered.

Thanks in advance.

What I have tried:

I just implemented windows service in c sharp and it works fine.

推荐答案

服务只是一个持续运行的应用程序,即使没有人登录也是如此。所以如果EXE是10mb那么它总是在内存中,即使是空闲。一个预定的应用程序在给定的时间启动你的进程,所以它将启动你的exe(我假设你的exe将在完成其工作时中止)在给定的时间将所有10MB加载到内存中,当EXE完成时它将释放10 MB 。



至于决斗服务,如果你有两个不同的服务exe文件在运行,并且都在10MB,那么它们一起需要20MB(每个10个),但是这样的情况我会看到我是否可以通过配置文件更改参数,并且让服务为每个配置实例完成工作。
A service is just an application that is constantly running, even if no-one is logged on. So if the EXE is 10mb then it'll be in memory always, even when "idle". A scheduled app starts your process at a given time, so it would launch your exe (I assume your exe will then abort when finished its work) at the given time loading all 10MB into memory and when the EXE finishes it will release that 10 MB.

As for the duel services, if you have two distinct service exe files running and both at 10MB then together they'll take 20MB (10 each), but in a circumstance like that I'd see if I could get a single service doing both functions, ie you could change the parameters via a config file and have the service do its work for each configuration instance.


这篇关于与任务调度程序或任务管理器相比,窗口服务如何在内部工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆