Visual Basic (Declaration) | |
---|---|
Public Overloads Overrides Function StartAsync() As Task(Of LocalService) |
C# | |
---|---|
public override Task<LocalService> StartAsync() |
The StartAsync method will perform various checks to ascertain the status of both the LocalMapService instance and the underlying LocalServer:
- First the LocalServiceStatus of the LocalMapService instance will be ascertained. In the cases that it is already LocalServiceStatus.Running or LocalServiceStatus.Starting the method will exit. If the LocalMapService creation failed, the current status will be LocalServiceStatus.StartError, and an InvalidOperationException will be thrown.
- The status of the LocalServer will then be confirmed. If the status is LocalServerStatus.Running the LocalMapService creation will continue. In the cases that the LocalServer is LocalServerStatus.NotInitialized or LocalServerStatus.Initializing an attempt will be made to start the LocalServer and execution will wait until the status is LocalServerStatus.Running at which point the attempt to create the LocalMapService will be remade. The status will also be LocalServiceStatus.StartError if the StartAsync method is called whilst the LocalServer is shutting down. If the underlying LocalServer encountered an error and failed to initialize correctly an exception will be raised, supplemented by the information contained within the LocalServer.InitializationError.
The StartAsync operation should be enclosed in a try-catch block to handle any exceptions raised.
Return Value
A Task object on which the Result property contains the LocalService instance.Exception | Description |
---|---|
System.InvalidOperationException | StartAsync should can not be called if the local service is already in the LocalServiceStatus.Running state. |
System.InvalidOperationException | The Path property must specify a valid Map Package. |
Target Platforms: Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family, Windows 7, Windows 8