public void Logout()
{
AutoResetEvent logoutEvent = new AutoResetEvent(false);
LogoutCallback callback =
delegate(List<UUID> inventoryItems) { logoutEvent.Set(); };
OnLogoutReply += callback;
// Send the packet requesting a clean logout
RequestLogout();
// Wait for a logout response. If the response is received, shutdown
// will be fired in the callback. Otherwise we fire it manually with
// a NetworkTimeout type
if (!logoutEvent.WaitOne(Client.Settings.LOGOUT_TIMEOUT, false))
Shutdown(DisconnectType.NetworkTimeout);
OnLogoutReply -= callback;
_CurrentSim = null;
}