protected virtual void RaiseOnFailedToEnableSharing(IcsConnection failedToEnableSharingFor, Exception exception) { if (OnFailedToEnableSharing != null && _lastFailedToEnableSharingFor != failedToEnableSharingFor) { if (_lastFailedToEnableSharingFor != null && _lastFailedToEnableSharingFor.Guid == failedToEnableSharingFor.Guid) { return; } _lastFailedToEnableSharingFor = failedToEnableSharingFor; _threadedEvents.BeginInvoke(OnFailedToEnableSharing, this, exception); // preventing error message for same network } }
public SharableConnection(IcsConnection conn) { this.Name = conn.Name; this.DeviceName = conn.DeviceName; this.Guid = conn.Guid; }
public SharableConnection(IcsConnection connection) { Name = connection.Name; DeviceName = connection.DeviceName; Guid = connection.Guid; }
private void ShareConnection(IcsConnection icsConnection) { // disable sharing first DisableSharing(false); if (icsConnection == null) { return; } #if TRACE LogExceptions.LogTrace(true, "ShareConnection -> " + icsConnection.Name); #endif Exception failedToSharException = null; // then enabled the sharing for (int i = 1; i < 10; i++) { try { if (_wlanManager.HostedNetworkState != WLAN_HOSTED_NETWORK_STATE.wlan_hosted_network_active) { Thread.Sleep(500); continue; } var privateConnectionGuid = _wlanManager.HostedNetworkInterfaceGuid; _icsManager.EnableIcs(icsConnection.Guid, privateConnectionGuid); // the connected network guid to internet SharedConnection = icsConnection; failedToSharException = null; #if TRACE LogExceptions.LogTrace(true, "ShareConnection.EnableIcs on try no:" + i); #endif return; } catch (Exception ex) { #if DEBUG LogExceptions.Log(ex); #endif failedToSharException = ex; Thread.Sleep(500); } } // if we have reached here that means the connection is failed to share with many tries if (failedToSharException != null) { #if TRACE LogExceptions.LogTrace(true, "ShareConnection is failed -> " + icsConnection.Name, failedToSharException.ToString()); #endif RaiseOnFailedToEnableSharing(icsConnection, failedToSharException); } else { #if TRACE LogExceptions.LogTrace(true, "ShareConnection is failed -> " + icsConnection.Name); #endif } }