• 大小: 4.46MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2022-11-18
  • 语言: Html/CSS
  • 标签: Topshelf  

资源简介

使用Topshelf创建Windows服务,详细介绍博客:http://www.cnblogs.com/jys509/p/4614975.html

资源截图

代码片段和文件信息

using log4net.Config;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Topshelf;

namespace TopshelfDemo
{
    class Program
    {
        public static void Main(string[] args)
        {
            var logCfg = new FileInfo(AppDomain.CurrentDomain.baseDirectory + “log4net.config“);
            xmlConfigurator.ConfigureAndWatch(logCfg);

            HostFactory.Run(x =>
            {
                x.Service(s =>
                {
                    s.ConstructUsing(name => new TownCrier());
                    s.WhenStarted(tc => tc.Start());              
                    s.WhenStopped(tc => tc.Stop());             
                });
                x.RunAsLocalSystem();

                x.SetDescription(“Sample Topshelf Host服务的描述“);
                x.SetDisplayName(“Stuff显示名称“);
                x.SetServiceName(“Stuff服务名称“);
            });
        }
    }
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2015-06-30 23:37  TopshelfDemo\
     目录           0  2015-07-02 01:09  TopshelfDemo\TopshelfDemo\
     文件         185  2015-07-02 00:54  TopshelfDemo\TopshelfDemo\App.config
     文件        1047  2015-07-02 01:05  TopshelfDemo\TopshelfDemo\Program.cs
     目录           0  2015-06-30 23:32  TopshelfDemo\TopshelfDemo\Properties\
     文件        1348  2015-06-30 23:32  TopshelfDemo\TopshelfDemo\Properties\AssemblyInfo.cs
     文件        3189  2015-07-02 01:09  TopshelfDemo\TopshelfDemo\TopshelfDemo.csproj
     文件         686  2015-07-02 01:07  TopshelfDemo\TopshelfDemo\TownCrier.cs
     目录           0  2015-07-01 23:38  TopshelfDemo\TopshelfDemo\bin\
     目录           0  2015-07-02 01:09  TopshelfDemo\TopshelfDemo\bin\Debug\
     文件        9728  2015-06-30 23:39  TopshelfDemo\TopshelfDemo\bin\Debug\Topshelf.Log4Net.dll
     文件      282112  2015-06-30 23:37  TopshelfDemo\TopshelfDemo\bin\Debug\Topshelf.dll
     文件        7680  2015-07-02 01:09  TopshelfDemo\TopshelfDemo\bin\Debug\TopshelfDemo.exe
     文件         185  2015-07-02 00:54  TopshelfDemo\TopshelfDemo\bin\Debug\TopshelfDemo.exe.config
     文件       15872  2015-07-02 01:09  TopshelfDemo\TopshelfDemo\bin\Debug\TopshelfDemo.pdb
     文件       24224  2015-07-02 01:05  TopshelfDemo\TopshelfDemo\bin\Debug\TopshelfDemo.vshost.exe
     文件         185  2015-07-02 00:54  TopshelfDemo\TopshelfDemo\bin\Debug\TopshelfDemo.vshost.exe.config
     文件        2032  2015-07-02 01:05  TopshelfDemo\TopshelfDemo\bin\Debug\log4net.config
     文件      301056  2015-06-30 23:39  TopshelfDemo\TopshelfDemo\bin\Debug\log4net.dll
     文件     1517265  2015-06-30 23:39  TopshelfDemo\TopshelfDemo\bin\Debug\log4net.xml
     目录           0  2015-07-02 01:10  TopshelfDemo\TopshelfDemo\bin\Release\
     文件        2032  2015-07-02 01:05  TopshelfDemo\TopshelfDemo\log4net.config
     目录           0  2015-06-30 23:32  TopshelfDemo\TopshelfDemo\obj\
     目录           0  2015-07-02 01:09  TopshelfDemo\TopshelfDemo\obj\Debug\
     文件        6970  2015-07-02 01:09  TopshelfDemo\TopshelfDemo\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
     目录           0  2015-07-02 01:10  TopshelfDemo\TopshelfDemo\obj\Debug\TempPE\
     文件           0  2015-06-30 23:32  TopshelfDemo\TopshelfDemo\obj\Debug\TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs
     文件           0  2015-06-30 23:32  TopshelfDemo\TopshelfDemo\obj\Debug\TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs
     文件           0  2015-06-30 23:32  TopshelfDemo\TopshelfDemo\obj\Debug\TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs
     文件         705  2015-07-02 01:09  TopshelfDemo\TopshelfDemo\obj\Debug\TopshelfDemo.csproj.FileListAbsolute.txt
     文件        7680  2015-07-02 01:09  TopshelfDemo\TopshelfDemo\obj\Debug\TopshelfDemo.exe
............此处省略47个文件信息

评论

共有 条评论

相关资源