Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to create WCF Windows

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article focuses on "how to create WCF Windows". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to create WCF Windows.

WCF Windows applications are applications that need to be run for a long time and are suitable for server environments. It does not have a separate starting home page, nor will it generate video output, and users' messages will be written to the WCF Windows event log.

When the computer starts, the service starts automatically. They do not need to be logged in to run, they can run in any user environment, including the system. Through the Service Control Manager, WCF Windows is controllable and can be terminated, paused, and started when needed.

WCF Windows services, formerly known as NT services, are introduced as part of the Windows NT operating system. They are not available under Windows 9x and Windows Me. You need to use a NT-level operating system to run WCF Windows, such as Windows NT, Windows 2000 Professional or Windows 2000 Server. For example, products in the form of Windows services include Microsoft Exchange, SQL Server, and other Windows Time services such as setting computer clocks.

Create a Windows service

The service we are about to create does nothing but demonstrate. When the service is started, an entry information is registered in a database to indicate that the service has been started. While the service is running, it periodically creates a database project record within a specified interval. A database record is created when the service is stopped. The service automatically registers with the Windows application log when it starts or stops successfully.

Visual Studio .NET can make it fairly easy to create a Windows service. The instructions for starting our demo service are summarized below.

1. Create a new project

two。 Select the WCF Windows service from a list of available project templates

3. The designer opens in design mode

4. Drag a Timer object from the component list in the toolbox onto the design surface (note: be sure to use Timer from the component list and not from the Windows forms list)

5. Set the Timer property, and the Enabled property is the False,Interval property 30000 milliseconds

6. Switch to the code view page (press F7 or select code from the view menu), and then add power to the service

The composition of WCF Windows

In the code included at the end of your class, you will notice that the Windows service you created extends the System.ServiceProcess.Service class. All WCF Windows built in. Net must extend this class. It will require your service to overload the following methods, which are included by default in Visual Studio.

◆ Dispose-clears any controlled and uncontrolled resources (managed and unmanaged resources)

◆ OnStart-Control service startup

◆ OnStop-Control Service stop

At this point, I believe you have a deeper understanding of "how to create WCF Windows". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report