RemotingServices.IsOneWay(MethodBase) Metodo
Definizione
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Restituisce un valore booleano che indica se il client che ha chiamato il metodo specificato nel messaggio specificato è in attesa che il server finisca l'elaborazione del metodo prima di continuare l'esecuzione.
public:
static bool IsOneWay(System::Reflection::MethodBase ^ method);
public static bool IsOneWay(System.Reflection.MethodBase method);
[System.Security.SecurityCritical]
public static bool IsOneWay(System.Reflection.MethodBase method);
static member IsOneWay : System.Reflection.MethodBase -> bool
[<System.Security.SecurityCritical>]
static member IsOneWay : System.Reflection.MethodBase -> bool
Public Shared Function IsOneWay (method As MethodBase) As Boolean
Parametri
- method
- MethodBase
Metodo in questione.
Valori restituiti
true se il metodo è un modo; in caso contrario, false.
- Attributi
Eccezioni
Il chiamante immediato non dispone dell'autorizzazione dell'infrastruttura.
Esempio
public ref class HelloServer: public MarshalByRefObject
{
public:
HelloServer()
{
Console::WriteLine( "HelloServer activated." );
}
[OneWay]
void SayHelloToServer( String^ name )
{
Console::WriteLine( "Client invoked SayHelloToServer(\" {0}\").", name );
}
// IsOneWay: Note the lack of the OneWayAttribute adornment on this method.
[SecurityPermissionAttribute(SecurityAction::Demand, Flags=SecurityPermissionFlag::Infrastructure)]
String^ SayHelloToServerAndWait( String^ name )
{
Console::WriteLine( "Client invoked SayHelloToServerAndWait(\" {0}\").", name );
Console::WriteLine( "Client waiting for return? {0}", RemotingServices::IsOneWay( MethodBase::GetCurrentMethod() ) ? (String^)"No" : "Yes" );
return String::Format( "Hi there, {0}.", name );
}
};
public class HelloServer : MarshalByRefObject {
public HelloServer() {
Console.WriteLine("HelloServer activated.");
}
[OneWay()]
public void SayHelloToServer(string name) {
Console.WriteLine("Client invoked SayHelloToServer(\"{0}\").", name);
}
// IsOneWay
// Note the lack of the OneWayAttribute adornment on this method.
public string SayHelloToServerAndWait(string name) {
Console.WriteLine("Client invoked SayHelloToServerAndWait(\"{0}\").", name);
Console.WriteLine(
"Client waiting for return? {0}",
RemotingServices.IsOneWay(MethodBase.GetCurrentMethod()) ? "No" : "Yes"
);
return "Hi there, " + name + ".";
}
}
Public Class HelloServer
Inherits MarshalByRefObject
Shared Sub New()
Console.WriteLine("HelloServer activated.")
End Sub
<OneWay()> Public Sub SayHelloToServer(ByVal name As String)
Console.WriteLine("Client invoked SayHelloToServer(""{0}"").", name)
End Sub
'IsOneWay
' Note the lack of the OneWayAttribute adornment on this method.
<SecurityPermission(SecurityAction.Demand)> _
Public Function SayHelloToServerAndWait(ByVal name As String) As String
Console.WriteLine("Client invoked SayHelloToServerAndWait(""{0}"").", name)
Console.WriteLine( _
"Client waiting for return? {0}", _
IIf(RemotingServices.IsOneWay(MethodBase.GetCurrentMethod()), "No", "Yes") _
)
Return "Hi there, " + name + "."
End Function
End Class
Commenti
Quando viene chiamato un metodo unidirezionale, il client non attende che il server termini l'elaborazione del messaggio. Il metodo client torna all'applicazione senza sapere se il server elaborerà correttamente il messaggio. I metodi vengono contrassegnati come un modo per usare .OneWayAttribute
I metodi unidirezionale non possono avere un valore restituito o parametri out.