RemotingServices.Disconnect(MarshalByRefObject) Metode
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
Menghentikan objek menerima pesan lebih lanjut melalui saluran jarak jauh terdaftar.
public:
static bool Disconnect(MarshalByRefObject ^ obj);
public static bool Disconnect (MarshalByRefObject obj);
[System.Security.SecurityCritical]
public static bool Disconnect (MarshalByRefObject obj);
static member Disconnect : MarshalByRefObject -> bool
[<System.Security.SecurityCritical>]
static member Disconnect : MarshalByRefObject -> bool
Public Shared Function Disconnect (obj As MarshalByRefObject) As Boolean
Parameter
Obyek untuk memutuskan sambungan dari salurannya.
Mengembalikan
true
jika objek terputus dari saluran jarak jauh terdaftar berhasil; jika tidak, false
.
- Atribut
Pengecualian
Parameternya obj
adalah null
.
Parameter obj
adalah proksi.
Penelepon langsung tidak memiliki izin untuk mengonfigurasi jenis dan saluran jarak jauh.
Contoh
Contoh kode berikut menunjukkan cara menggunakan Disconnect metode untuk memutuskan sambungan objek dari saluran jarak jauh.
TcpChannel^ channel = gcnew TcpChannel( 9000 );
ChannelServices::RegisterChannel( channel );
SampleWellKnown ^ objectWellKnown = gcnew SampleWellKnown;
// After the channel is registered, the Object* needs to be registered
// with the remoting infrastructure. So, Marshal is called.
ObjRef^ objrefWellKnown = RemotingServices::Marshal( objectWellKnown, "objectWellKnownUri" );
Console::WriteLine( "An instance of SampleWellKnown type is published at {0}.", objrefWellKnown->URI );
Console::WriteLine( "Press enter to unregister SampleWellKnown, so that it is no longer available on this channel." );
Console::ReadLine();
RemotingServices::Disconnect( objectWellKnown );
Console::WriteLine( "Press enter to end the server process." );
Console::ReadLine();
TcpChannel channel = new TcpChannel(9000);
ChannelServices.RegisterChannel(channel);
SampleWellKnown objectWellKnown = new SampleWellKnown();
// After the channel is registered, the object needs to be registered
// with the remoting infrastructure. So, Marshal is called.
ObjRef objrefWellKnown = RemotingServices.Marshal(objectWellKnown, "objectWellKnownUri");
Console.WriteLine("An instance of SampleWellKnown type is published at {0}.", objrefWellKnown.URI);
Console.WriteLine("Press enter to unregister SampleWellKnown, so that it is no longer available on this channel.");
Console.ReadLine();
RemotingServices.Disconnect(objectWellKnown);
Console.WriteLine("Press enter to end the server process.");
Console.ReadLine();
Dim channel As New TcpChannel(9000)
ChannelServices.RegisterChannel(channel)
Dim objectWellKnown As New SampleWellKnown()
' After the channel is registered, the object needs to be registered
' with the remoting infrastructure. So, Marshal is called.
Dim objrefWellKnown As ObjRef = RemotingServices.Marshal(objectWellKnown, "objectWellKnownUri")
Console.WriteLine("An instance of SampleWellKnown type is published at {0}.", objrefWellKnown.URI)
Console.WriteLine("Press enter to unregister SampleWellKnown, so that it is no longer available on this channel.")
Console.ReadLine()
RemotingServices.Disconnect(objectWellKnown)
Console.WriteLine("Press enter to end the server process.")
Console.ReadLine()