CollaborationPlatform.BeginStartup(AsyncCallback, Object) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Initializes the platform object.
public:
IAsyncResult ^ BeginStartup(AsyncCallback ^ userCallback, System::Object ^ state);
public IAsyncResult BeginStartup (AsyncCallback userCallback, object state);
member this.BeginStartup : AsyncCallback * obj -> IAsyncResult
Public Function BeginStartup (userCallback As AsyncCallback, state As Object) As IAsyncResult
Parameters
- userCallback
- AsyncCallback
The method to be called when the asynchronous operation is completed.
- state
- Object
A user-provided object that distinguishes this particular asynchronous operation from other asynchronous operations.
Returns
An IAsyncResult that references the asynchronous operation.
Exceptions
Thrown when the platform has already been started or has been terminated.
Examples
The following example shows how to start a server platform that uses auto-provisioning. The example assumes the server has been configured to support provisioning of the application.
C# Server platform initialization with provisioning
private void PlatformStartupCompleted(IAsyncResult result)
{
try
{
CollaborationPlatform platform = result.AsyncState as CollaborationPlatform;
platform.EndStartup(result);
Console.WriteLine("Platform started.");
}
catch (RealTimeException exception)
{
// TODO: Replace with error handling code.
Console.WriteLine("Platform startup failed: {0}", exception.Message);
}
finally
{
// TODO: Put any clean up code here.
}
}
private void Platform_ApplicationEndpointOwnerDiscovered(
object sender/*platform*/,
ApplicationEndpointSettingsDiscoveredEventArgs e)
{
try
{
CollaborationPlatform platform = sender as CollaborationPlatform;
// A new endpoint was added. The configured settings can be retrieved.
ApplicationEndpointSettings settings = e.ApplicationEndpointSettings;
// Customize additional settings if required
settings.OwnerPhoneUri = "tel:+14255553333";
ApplicationEndpoint endpoint = new ApplicationEndpoint(platform, settings);
// Save the active endpoint in the list.
m_endpoints.Add(endpoint);
// Register event handlers
endpoint.RegisterForIncomingCall<InstantMessagingCall>(this.InstantMessagingCallReceived);
endpoint.StateChanged += this.Endpoint_StateChanged;
endpoint.OwnerPropertiesChanged += this.Endpoint_OwnerPropertiesChanged;
endpoint.BeginEstablish(this.EndpointEstablishCompleted, endpoint/*state*/);
}
catch (InvalidOperationException)
{
// Platform was shutdown on another thread
// TODO: Replace with error handling code.
Console.WriteLine("Could not establish endpoint. Platform was not in a valid state.");
}
}
private void Endpoint_StateChanged(object sender /*endpoint*/, LocalEndpointStateChangedEventArgs e)
{
// When the endpoint is terminated because of a contact being deleted,
// the application receives Terminating and Terminated state changes.
Console.WriteLine("Endpoint state changed from {0} to {1}", e.PreviousState.ToString(), e.State.ToString());
}
private void Endpoint_OwnerPropertiesChanged(object sender /*endpoint*/, ApplicationEndpointOwnerPropertiesChangedEventArgs e)
{
// When owner properties data for the endpoint changes the OwnerPropertiesChanged event is raised,
// so find out what has changed.
}
private void EndpointEstablishCompleted(IAsyncResult result)
{
try
{
LocalEndpoint endpoint = result.AsyncState as LocalEndpoint;
endpoint.EndEstablish(result);
}
catch (RealTimeException exception)
{
// TODO: Replace with error handling code.
Console.WriteLine("Failed to establish endpoint: {0}", exception.Message);
}
finally
{
// TODO: Add clean up code here.
}
}
The following example shows how to start a server platform that uses auto-provisioning. The example assumes the server has been configured to support provisioning of the application.
C# Server platform initialization with provisioning
private void PlatformStartupCompleted(IAsyncResult result)
{
try
{
CollaborationPlatform platform = result.AsyncState as CollaborationPlatform;
platform.EndStartup(result);
Console.WriteLine("Platform started.");
}
catch (RealTimeException exception)
{
// TODO: Replace with error handling code.
Console.WriteLine("Platform startup failed: {0}", exception.Message);
}
finally
{
// TODO: Put any clean up code here.
}
}
The following example shows how to start a server platform that uses auto-provisioning. The example assumes the server has been configured to support provisioning of the application.
C# Server platform initialization with provisioning
private void PlatformStartupCompleted(IAsyncResult result)
{
try
{
CollaborationPlatform platform = result.AsyncState as CollaborationPlatform;
platform.EndStartup(result);
Console.WriteLine("Platform started.");
}
catch (RealTimeException exception)
{
// TODO: Replace with error handling code.
Console.WriteLine("Platform startup failed: {0}", exception.Message);
}
finally
{
// TODO: Put any clean up code here.
}
}
Remarks
Once the platform is started up it can be used to create endpoints. In case of auto-provisioned CollaborationPlatform the provisioning information for the application is fetched during startup. It also subscribes to changes in provisioning information such as addition or removal of application endpoint owners, changes to configured certificate, etc.