导出 (0) 打印
全部展开

RoleEnvironment.CurrentRoleInstance 属性

Gets a RoleInstance object that represents the role instance in which the code is currently running.

命名空间: Microsoft.WindowsAzure.ServiceRuntime
程序集: Microsoft.WindowsAzure.ServiceRuntime(在 microsoft.windowsazure.serviceruntime.dll 中)

用法
Dim value As RoleInstance

value = RoleEnvironment.CurrentRoleInstance

public static RoleInstance CurrentRoleInstance { get; }
/** @property */
public static RoleInstance get_CurrentRoleInstance ()

public static function get CurrentRoleInstance () : RoleInstance

属性值

An instance of RoleInstance.

A role is a component of an application that performs specific functionality, such as running a website or performing background tasks. A role instance is a running copy of the role in Windows Azure or the Windows Azure Compute Emulator. A role must have endpoints defined to communicate internally and externally. The following code example shows how to retrieve endpoint information for the current role instance:


var roleInstance = RoleEnvironment.CurrentRoleInstance; 
foreach (RoleInstanceEndpoint instanceEndpoint in roleInstance.InstanceEndpoints.Values) 
{  
   Trace.WriteLine("Instance endpoint address and port: " + instanceEndpoint.IPEndpoint, "Information");
   Trace.WriteLine("Protocol for the endpoint: " + , instanceEndpoint.Protocol, "Information");
}

此类型的任何公共静态(在 Visual Basic 中为 Shared)成员都是线程安全的。但不保证所有实例成员都是线程安全的。

开发平台

Windows XP Home Edition, Windows XP Professional, Windows Server 2003、Windows Server 2008 和 Windows 2000

目标平台

社区附加资源

显示:
© 2014 Microsoft