Esempio n. 1
0
        /// <summary>
        ///  Adds session event to queue and uploads
        /// </summary>
        /// <param name="sessionEvent">session event object</param>
        /// <param name="uploadImmediately">indicates when start to upload, by default - immediately after event was added</param>
        private static async Task AddSessionEvent(SessionEvent sessionEvent, bool uploadImmediately = true)
        {
            if (String.IsNullOrWhiteSpace(ServerUrl))
            {
                throw new InvalidOperationException("session is not active");
            }
            
            lock (sync)
            {
                Sessions.Add(sessionEvent);

                SaveSessions();
            }

            if (uploadImmediately)
            {
                await Upload();
            }
        }
        /// <summary>
        ///  Adds session event to queue and uploads
        /// </summary>
        /// <param name="sessionEvent">session event object</param>
        /// <param name="uploadImmediately">indicates when start to upload, by default - immediately after event was added</param>
        private static void AddSessionEvent(SessionEvent sessionEvent, bool uploadImmediately = true)
        {
            if (String.IsNullOrWhiteSpace(ServerUrl))
            {
                throw new InvalidOperationException("session is not active");
            }

            ThreadPool.QueueUserWorkItem(async (work) =>
            {
                lock (sync)
                {
                    Sessions.Add(sessionEvent);

                    SaveSessions();
                }

                if (uploadImmediately)
                {
                    await Upload();
                }
            });
        }
Esempio n. 3
0
        /// <summary>
        ///  Adds session event to queue and uploads
        /// </summary>
        /// <param name="sessionEvent">session event object</param>
        /// <param name="uploadImmediately">indicates when start to upload, by default - immediately after event was added</param>
        private static async Task AddSessionEvent(SessionEvent sessionEvent, bool uploadImmediately = true)
        {
            try
            {
                if (String.IsNullOrEmpty(ServerUrl))
                {
                    throw new InvalidOperationException("session is not active");
                }

                lock (sync)
                {
                    Sessions.Add(sessionEvent);

                    SaveSessions();
                }

                if (uploadImmediately)
                {
                    await Upload();
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }
        }