Esempio n. 1
0
        public void Reset()
        {
            lock (this)
            {
                if (readPacket != null)
                {
                    try
                    {
                        readPacket.DetachStream();
                        readPacket = null;
                    }
                    catch (Exception exp)
                    {
                        Diag.DebugPrint("Could not detach DataReader: " + exp.Message);
                    }
                }

                if (writePacket != null)
                {
                    try
                    {
                        writePacket.DetachStream();
                        writePacket = null;
                    }
                    catch (Exception exp)
                    {
                        Diag.DebugPrint("Could not detach DataWriter: " + exp.Message);
                    }
                }

                if (socket != null)
                {
                    socket.Dispose();
                    socket = null;
                }

                if (channel != null)
                {
                    if (((IDictionary <string, object>)CoreApplication.Properties).ContainsKey(channel.ControlChannelTriggerId))
                    {
                        CoreApplication.Properties.Remove(channel.ControlChannelTriggerId);
                    }

                    // Call the Dispose() method on the controlchanneltrigger object to release any
                    // OS maintained resources for this channel object.
                    channel.Dispose();
                    channel = null;
                }
                Diag.DebugPrint("CommModule has been reset.");
            }
        }
Esempio n. 2
0
        private bool UnregisterControlChannel()
        {
            try
            {
                // Renew Socket
                if (_XMPP.Socket != null)
                {
                    _XMPP.Socket.Dispose();
                }

                // Unregister leftovers
                foreach (var task in BackgroundTaskRegistration.AllTasks)
                {
                    if (task.Value.Name.StartsWith("PN" + Id) || task.Value.Name.StartsWith("KA" + Id))
                    {
                        task.Value.Unregister(true);
                    }
                }

                if (_controlChannel != null)
                {
                    _controlChannel.Dispose();
                }
            }
            catch
            {
                PushEvent(ErrorType.UnregisterControlChannel, ErrorPolicyType.Reconnect);
                return(false);
            }
#if DEBUG
            PushEvent(LogType.Info, "ControlChanel unregistered");
#endif
            return(true);
        }
 private void DisposeProperties()
 {
     Diag.DebugPrint("Entering cleanup");
     if (httpClient != null)
     {
         httpClient.Dispose();
         httpClient = null;
     }
     if (channel != null)
     {
         channel.Dispose();
         channel = null;
     }
     Diag.DebugPrint("Exiting cleanup");
 }