コード例 #1
0
        private void exceptionHandler(object sender, UnhandledExceptionEventArgs e)
        {
            var exception = (Exception)e.ExceptionObject;

            Logger.Error(exception, @"fatal error:", recursive: true);

            var exInfo = ExceptionDispatchInfo.Capture(exception);

            if (ExceptionThrown?.Invoke(exception) != true)
            {
                AppDomain.CurrentDomain.UnhandledException -= exceptionHandler;

                //we want to throw this exception on the input thread to interrupt window and also headless execution.
                InputThread.Scheduler.Add(() => { exInfo.Throw(); });
            }
        }
コード例 #2
0
        public void StopListen()
        {
            foreach (var server in _serverStreams.Values)
            {
                try
                {
                    UnregisterFromServerEvents(server);
                    server.StopListen();
                }
                catch (Exception ex)
                {
                    ExceptionThrown?.Invoke(this, ex);
                }
            }

            _serverStreams.Clear();
        }
コード例 #3
0
        /// <exception cref="Exception">Throwing exception if in debug mode and not exception handler have been specified.</exception>
        private void OnRequest(object sender, RequestEventArgs e)
        {
            var context = (HttpContext)sender;

            HttpFactory.Current = Factory;
            HttpContext.Current = context;

            try
            {
                var args = new RequestEventArgs(context, e.Request, e.Response);
                RequestReceived(this, args);
                if (!args.IsHandled)
                {
                    // need to respond to the context.
                    var generator = new ResponseWriter();
                    generator.Send(context, args.Response);
                }

                // Disconnect when done.
                if (e.Response.HttpVersion == "HTTP/1.0" || e.Response.Connection.Type == ConnectionType.Close)
                {
                    context.Disconnect();
                }
            }
            catch (Exception err)
            {
                if (err is HttpException)
                {
                    var exception = (HttpException)err;
                    ErrorPage(e.Request, e.Response, exception);
                }
                else
                {
                    _logger.Debug("Request failed.", err);
#if DEBUG
                    if (ExceptionThrown.GetInvocationList().Length == 1)
                    {
                        throw;
                    }
#endif
                    ExceptionThrown(this, new ExceptionEventArgs(err));
                    SendInternalServerError(context, err);
                }
            }
        }
コード例 #4
0
        private TestResult EnsureCorrectTestResult(MemberInfo method)
        {
            TestResult result = new TestResult();

            object[] attribute = method.GetCustomAttributes(typeof(ExceptionThrown), true);

            if (attribute.Length > 0)
            {
                ExceptionThrown expectedException = attribute[0] as ExceptionThrown;
                result.Passed     = false;
                result.ResultText = string.Format("Exception of type {0} was expected", expectedException.ExceptionType);
                return(result);
            }

            result.Passed     = true;
            result.ResultText = GetTestPassedMessage(method.Name);
            return(result);
        }
コード例 #5
0
 /// <summary>
 /// Sends a message to the session.
 /// </summary>
 /// <param name="message"></param>
 public void Send(T message)
 {
     try {
         Transceiver.Transmit(Stream, message);
     }
     catch (Exception x) {
         var source = $"{GetType().Name}.{MethodBase.GetCurrentMethod().Name}";
         if (String.IsNullOrEmpty(x.Source))
         {
             x.Source = source;
         }
         else
         {
             x.Source += $"; {source}";
         }
         ExceptionThrown?.Invoke(this, new ExceptionEventArgs(x));
     }
 }
コード例 #6
0
ファイル: VSharpMonitor.cs プロジェクト: robindz/VSharp
        private void UnregisterSubtitleMonitor(int videoSeq, string locale, string type)
        {
            ValidateStrictlyPostiveInteger(videoSeq, nameof(videoSeq));

            lock (_lock)
            {
                string key = $"{videoSeq}_{locale}_{type}";
                if (_subtitleTasks.ContainsKey(key))
                {
                    _subtitleTasks[key].StopTask();
                    bool success = _subtitleTasks.TryRemove(key, out SubtitleMonitorTask _);
                    if (!success)
                    {
                        ExceptionThrown.Invoke(null, new FailedToUnregisterSubtitleMonitorException(videoSeq, locale, type, Monitor.Subtitle, "Failed to unregister a task with the monitor service."));
                    }
                }
            }
        }
コード例 #7
0
ファイル: SubtitleMonitorTask.cs プロジェクト: robindz/VSharp
        public SubtitleMonitorTask(int videoSeq, Language language, SubtitleType type, TimeSpan period, VSharpService service) : base(videoSeq, period, service)
        {
            Language = language;
            Type     = type;
            Id       = new SubtitleMonitorTaskId(videoSeq, language, type);

            Timer = new Timer(async(s) =>
            {
                if (Checking)
                {
                    return;
                }

                // Set flag to prevent overlapping checks
                Checking = true;

                try
                {
                    VODInfo vodInfo = await Service.GetVODInfoAsync(VideoSeq);

                    // Only continue if the VOD has caption data
                    if (vodInfo.CaptionInfo == null)
                    {
                        return;
                    }

                    foreach (var details in vodInfo.CaptionInfo.Details)
                    {
                        if (details.Locale == Language.Value && details.Type.ToLower() == Type.Value)
                        {
                            SubtitleAvailable.Invoke(null, CreateSubtitleEventArgs(VideoSeq, details));
                        }
                    }
                }
                catch (Exception e)
                {
                    ExceptionThrown.Invoke(null, e);
                }
                finally
                {
                    Checking = false;
                }
            }, null, Timeout.Infinite, Timeout.Infinite);
        }
コード例 #8
0
        private PipeSecurity GetPipeSecurity()
        {
            PipeSecurity ps = null;

            try
            {
                ps = new PipeSecurity();
                var sid = new SecurityIdentifier(WellKnownSidType.WorldSid, null); //LocalSystemSid
                //ps.AddAccessRule(new PipeAccessRule(sid, PipeAccessRights.ReadWrite, AccessControlType.Allow););

                //ps.AddAccessRule(new PipeAccessRule(myPipeUsersGroup, PipeAccessRights.ReadWrite, AccessControlType.Allow));
                ps.AddAccessRule(new PipeAccessRule(sid, PipeAccessRights.FullControl, AccessControlType.Allow));
            }
            catch (Exception ex)
            {
                ExceptionThrown?.Invoke(PipeName, ex);
            }
            return(ps);
        }
コード例 #9
0
        private void WorkingLoop()
        {
            try
            {
                IntPtr ptrPacket = IntPtr.Zero;
                IntPtr ptrHeader = IntPtr.Zero;

                while (bRun)
                {
                    int iReturn = pcap_next_ex(iptrOpenDevice, ref ptrHeader, ref ptrPacket);
                    if (iReturn == 1)
                    {
                        OnPacketCaptured(IntPtr.Zero, (PcapPacketHeader)Marshal.PtrToStructure(ptrHeader, typeof(PcapPacketHeader)), ptrPacket);
                    }
                    else if (iReturn == -1)
                    {
                        throw new Exception("An error occurred while reading from a WinPcap interface. (Error number: " + iReturn + ")");
                    }
                }

                ptrPacket = IntPtr.Zero;
                ptrHeader = IntPtr.Zero;
            }
            catch (Exception ex)
            {
                if (ExceptionThrown != null)
                {
                    foreach (Delegate dDelgate in ExceptionThrown.GetInvocationList())
                    {
                        if (dDelgate.Target != null && dDelgate.Target is System.ComponentModel.ISynchronizeInvoke &&
                            ((System.ComponentModel.ISynchronizeInvoke)(dDelgate.Target)).InvokeRequired)
                        {
                            ((System.ComponentModel.ISynchronizeInvoke)(dDelgate.Target)).BeginInvoke(dDelgate, new object[] { this, new ExceptionEventArgs(ex, DateTime.Now) });
                        }
                        else
                        {
                            ((eExNetworkLibrary.TrafficHandler.ExceptionEventHandler)dDelgate)(this, new ExceptionEventArgs(ex, DateTime.Now));
                        }
                    }
                }
            }
        }
コード例 #10
0
        public void StopListen()
        {
            _isStopping = true;

            try
            {
                if (_serverStream.IsConnected)
                {
                    _serverStream.Disconnect();
                }
            }
            catch (Exception ex)
            {
                ExceptionThrown?.Invoke(this, ex);
            }
            finally
            {
                _serverStream.Close();
                _serverStream.Dispose();
            }
        }
コード例 #11
0
ファイル: PacketReader.cs プロジェクト: Jukspa/DemoSplicer
        public void Parse()
        {
            try
            {
                int type = 0;
                var bb   = new BitBuffer(Data);
                while (bb.BitsLeft > NetMessageBits && !ShouldStop)
                {
                    var dataBitWriter        = new BitWriterDeluxe();
                    var withoutTypeBitWriter = new BitWriterDeluxe();
                    int startIndex           = bb.CurrentBit;

                    type = (int)bb.ReadUnsignedBits(NetMessageBits);
                    MessageTypeRead?.Invoke(this, new MessageReceivedEventArgs(type, bb));
                    int withoutTypeIndex = bb.CurrentBit;

                    MsgHandler handler;
                    if (Handlers.TryGetValue((uint)type, out handler))
                    {
                        handler(bb);
                        dataBitWriter.WriteRangeFromArray(Data, startIndex, bb.CurrentBit);
                        withoutTypeBitWriter.WriteRangeFromArray(Data, withoutTypeIndex, bb.CurrentBit);

                        var bytes  = dataBitWriter.Data;
                        var bytes2 = withoutTypeBitWriter.Data;
                        MessageRead?.Invoke(this, new DataReadEventArgs(bytes, dataBitWriter, bytes2, withoutTypeBitWriter, type));
                    }
                    else
                    {
                        throw new Exception("Unknown packet type found.");
                    }
                }

                PacketSuccessfullyRead?.Invoke(this, new EventArgs());
            }
            catch (Exception e)
            {
                ExceptionThrown?.Invoke(this, new ExceptionEventArgs(e));
            }
        }
コード例 #12
0
ファイル: LiveMonitorTask.cs プロジェクト: robindz/VSharp
        public LiveMonitorTask(int channelSeq, int count, TimeSpan period, VSharpService service) : base(channelSeq, period, service)
        {
            _count = count;

            Timer = new Timer(async(s) =>
            {
                if (Checking)
                {
                    return;
                }

                // Set flag to prevent overlapping checks
                Checking = true;

                try
                {
                    ChannelVideoListResponse channelVideoListResponse = await Service.GetChannelVideoListAsync(ChannelSeq, _count, 1);
                    List <Video> videos = channelVideoListResponse.Videos;

                    videos = videos.Where(x => x.VideoType == "LIVE" && x.OnAirStartAt > lastLive).ToList();
                    for (int i = videos.Count - 1; i >= 0; i--)
                    {
                        LiveFound.Invoke(null, CreateLiveFoundEventArgs(videos[i], channelVideoListResponse.ChannelInfo));
                    }

                    if (videos.Any())
                    {
                        lastLive = videos.Max(x => x.OnAirStartAt);
                    }
                }
                catch (Exception e)
                {
                    ExceptionThrown.Invoke(null, e);
                }
                finally
                {
                    Checking = false;
                }
            }, null, Timeout.Infinite, Timeout.Infinite);
        }
コード例 #13
0
        public async Task <ResponseInfo> SendAsync(
            Func <HttpRequestMessage> generator,
            int maximalRetryAttempt = 5)
        {
            var policy = Policy
                         .Handle <HttpRequestException>()
                         .OrResult <ResponseInfo>(response =>
                                                  response.Status is >= HttpStatusCode.InternalServerError or HttpStatusCode.RequestTimeout)
                         .WaitAndRetryAsync(
                maximalRetryAttempt,
                attempt => TimeSpan.FromSeconds(attempt),
                (result, span, attempt, _) => ReceiveFailed?.Invoke(result, span, attempt));

            ResponseInfo info;

            try
            {
                info = await policy.ExecuteAsync(async() =>
                {
                    using var msg = generator();
                    using var res = await Client.SendAsync(msg);

                    return(await res.Content
                           .Decompress()
                           .ContinueWith(t => new ResponseInfo(t.Result, res.StatusCode)));
                });
            }
            catch (TaskCanceledException)
            {
                TaskCanceled?.Invoke();
                return(null);
            }
            catch (Exception e)
            {
                ExceptionThrown?.Invoke(e);
                return(null);
            }

            return(info);
        }
コード例 #14
0
        public ByteData WriteAndGetReply(byte[] data, TimeSpan timeout)
        {
            if (this.SerialPort == null)
            {
                return(null);
            }
            this.reply = null;
            this.SerialPort.ReadTimeout = (int)timeout.TotalMilliseconds;
            if (!this.Write(data))
            {
                return(null);
            }

            this.hasReplied.Reset();
            if (!this.hasReplied.WaitOne(timeout))
            {
                this.reply = null;
                ExceptionThrown?.Invoke(this, new Exception("Reply timeout"));
            }

            return(this.reply);
        }
コード例 #15
0
        string GetExceptionMessage()
        {
            string  message = "";
            Version v       = Assembly.GetEntryAssembly().GetName().Version;

            message += "App Version : " + v.ToString() + Environment.NewLine;
            message += ".NET Version : " + Environment.Version.ToString() + Environment.NewLine;
            message += "OS Version : " + Environment.OSVersion.ToString() +
                       string.Format(", {0}bit", IntPtr.Size == 4 ? 32 : 64) + Environment.NewLine;

            string cultureName = null;

            try {
                cultureName = CultureInfo.CurrentCulture.Name;
                message    += "Current culture : " + CultureInfo.CurrentCulture.EnglishName +
                              " (" + cultureName + ")" + Environment.NewLine;
            } catch { }

            try {
                if (SystemInformation.TerminalServerSession)
                {
                    message += "Terminal Server Session" + Environment.NewLine;
                }
                if (SystemInformation.BootMode != BootMode.Normal)
                {
                    message += "Boot Mode            : " + SystemInformation.BootMode + Environment.NewLine;
                }
            } catch { }

            message += "Working Set Memory : " + (Environment.WorkingSet / 1024) + "kb" + Environment.NewLine;
            message += "GC Heap Memory : " + (GC.GetTotalMemory(false) / 1024) + "kb" + Environment.NewLine;
            message += Environment.NewLine;

            message += "Exception thrown : " + Environment.NewLine;
            message += ExceptionThrown.ToString();

            return(message);
        }
コード例 #16
0
ファイル: VSharpMonitor.cs プロジェクト: robindz/VSharp
        public void RegisterSubtitleMonitor(int videoSeq, Language language, SubtitleType type, TimeSpan timespan)
        {
            ValidateStrictlyPostiveInteger(videoSeq, nameof(videoSeq));

            lock (_lock)
            {
                SubtitleMonitorTask task = new SubtitleMonitorTask(videoSeq, language, type, timespan, _service);
                if (!_subtitleTasks.ContainsKey(task.Id.Value))
                {
                    task.ExceptionThrown   += ExceptionThrownRepeater;
                    task.SubtitleAvailable += SubtitleAvailableRepeater;
                    bool success = _subtitleTasks.TryAdd(task.Id.Value, task);
                    if (!success)
                    {
                        ExceptionThrown.Invoke(null, new FailedToRegisterSubtitleMonitorException(videoSeq, language.Value, type.Value, Monitor.Subtitle, "Failed to register a task with the monitor service."));
                    }
                    else
                    {
                        task.StartTask();
                    }
                }
            }
        }
コード例 #17
0
 private void DoDispatching()
 {
     lock (_dispatchQueue) {
         var originalCount = _dispatchQueue.Count;
         while (originalCount > 0 && _dispatchQueue.Count > 0)
         {
             try {
                 var a = _dispatchQueue.Dequeue();
                 originalCount--;
                 if (a != null)
                 {
                     a();
                 }
             }
             catch (Exception e) {
                 if (ExceptionThrown != null)
                 {
                     ExceptionThrown.Invoke(e);
                 }
             }
         }
     }
 }
コード例 #18
0
        public static void Import(ApplicationSettingsBase config, string path)
        {
            XDocument xml = XDocument.Load(path);

            try
            {
                // validate config before importing
                const string typeParam  = "ReportType";
                string       configType = (string)config.GetType().GetProperty(typeParam).GetValue(config);
                string       xmlType    = xml.Root.Element(typeParam).Value;
                if (!string.Equals(configType, xmlType))
                {
                    throw new Exception();
                }

                // starting importing
                var props = config.GetType().GetProperties(
                    BindingFlags.DeclaredOnly |
                    BindingFlags.Instance |
                    BindingFlags.Public);
                foreach (var p in props)
                {
                    if (p.Name == typeParam)
                    {
                        continue;
                    }
                    var pt = p.PropertyType;
                    p.SetValue(config, Convert.ChangeType(xml.Root.Element(p.Name).Value, pt));
                }
            }
            catch
            {
                string errormsg = "Invalid config!";
                Console.WriteLine(errormsg);
                ExceptionThrown?.Invoke(Default, new EventArgs <string>(errormsg));
            }
        }
コード例 #19
0
ファイル: IpcEngineBase.cs プロジェクト: ss346/NetIpc
        private void OnIpcListenerExceptionThrown(object sender, Exception ex)
        {
            var outerEx = new Exception($"{_engineName}IPC listener error", ex);

            ExceptionThrown?.Invoke(this, outerEx);
        }
コード例 #20
0
 protected virtual void OnExceptionThrown(Exception e) => ExceptionThrown.ThrowIfUnhandled(this, e);
コード例 #21
0
ファイル: Proxy.cs プロジェクト: HTD/Woof.Sockets
 /// <summary>
 /// Handles exceptions from all sessions.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Session_ExceptionThrown(object sender, SystemEx.ExceptionEventArgs e) => ExceptionThrown?.Invoke(sender, e);
コード例 #22
0
 protected virtual void OnExceptionThrown(YaWhoisClientEventArgs e)
 {
     ExceptionThrown?.Invoke(this, e);
     WhenExceptionThrown?.Invoke(this, e);
 }
コード例 #23
0
 private void HandleExceptionData(ExceptionData data)
 {
     ExceptionThrown?.Invoke(data);
 }
コード例 #24
0
ファイル: VSharpMonitor.cs プロジェクト: robindz/VSharp
 private void ExceptionThrownRepeater(object sender, Exception e)
 {
     ExceptionThrown.Invoke(sender, e);
 }
コード例 #25
0
 private void OnExceptionThrown(Exception ex)
 {
     ExceptionThrown?.Invoke(this, ex);
     Hide();
 }
コード例 #26
0
        public void Dispose()
        {
            // Clearing all of these ensures that the transient APIs
            // can't be called outside of the appropriate scope.

            #region dispose-dispatcher service-apis
            _GetNuGetExePath             = null;
            _GetNuGetDllPath             = null;
            _DownloadFile                = null;
            _AddPinnedItemToTaskbar      = null;
            _RemovePinnedItemFromTaskbar = null;
            _CreateShortcutLink          = null;
            _UnzipFileIncremental        = null;
            _UnzipFile                 = null;
            _AddFileAssociation        = null;
            _RemoveFileAssociation     = null;
            _AddExplorerMenuItem       = null;
            _RemoveExplorerMenuItem    = null;
            _SetEnvironmentVariable    = null;
            _RemoveEnvironmentVariable = null;
            _AddFolderToPath           = null;
            _RemoveFolderFromPath      = null;
            _InstallMSI                = null;
            _RemoveMSI                 = null;
            _StartProcess              = null;
            _InstallVSIX               = null;
            _UninstallVSIX             = null;
            _InstallPowershellScript   = null;
            _UninstallPowershellScript = null;
            _SearchForExecutable       = null;
            _GetUserBinFolder          = null;
            _GetSystemBinFolder        = null;
            _CopyFile                = null;
            _CopyFolder              = null;
            _Delete                  = null;
            _DeleteFolder            = null;
            _CreateFolder            = null;
            _DeleteFile              = null;
            _BeginTransaction        = null;
            _AbortTransaction        = null;
            _EndTransaction          = null;
            _GenerateUninstallScript = null;
            _GetKnownFolder          = null;
            _IsElevated              = null;
            #endregion

            #region dispose-dispatcher core-apis
            _Warning          = null;
            _Message          = null;
            _Error            = null;
            _Debug            = null;
            _Verbose          = null;
            _ExceptionThrown  = null;
            _Progress         = null;
            _ProgressComplete = null;
            _GetHostDelegate  = null;
            _IsCancelled      = null;
            #endregion

            #region dispose-dispatcher request-apis
            _OkToContinue                       = null;
            _YieldPackage                       = null;
            _YieldPackageDetails                = null;
            _YieldPackageSwidtag                = null;
            _YieldSource                        = null;
            _YieldMetadataDefinition            = null;
            _YieldInstallationOptionsDefinition = null;
            #endregion

            #region dispose-dispatcher host-apis
            _GetMetadataKeys             = null;
            _GetMetadataValues           = null;
            _GetInstallationOptionKeys   = null;
            _GetInstallationOptionValues = null;
            _PackageSources   = null;
            _GetConfiguration = null;
            _ShouldContinueWithUntrustedPackageSource = null;
            _ShouldProcessPackageInstall                = null;
            _ShouldProcessPackageUninstall              = null;
            _ShouldContinueAfterPackageInstallFailure   = null;
            _ShouldContinueAfterPackageUninstallFailure = null;
            _ShouldContinueRunningInstallScript         = null;
            _ShouldContinueRunningUninstallScript       = null;
            _AskPermission = null;
            _WhatIf        = null;
            #endregion

            #region dispose-dispatcher protocol-apis
            _ProtocolGetNames        = null;
            _ProtocolIsValidSource   = null;
            _ProtocolGetItemMetadata = null;
            _ProtocolDownloadItem    = null;
            _ProtocolUnpackItem      = null;
            _InstallItem             = null;
            #endregion

            _callback = null;
        }
コード例 #27
0
 public bool ExceptionThrown(string exceptionType, string message, string stacktrace)
 {
     CheckDisposed();
     return((_ExceptionThrown ?? (_ExceptionThrown = (_callback.Resolve <ExceptionThrown>() ?? ((pexceptionType, pmessage, pstacktrace) => default(bool)))))(exceptionType, message, stacktrace));
 }
コード例 #28
0
        public bool Start(SoundSource music, int startTick)
        {
            if (Playing)
            {
                throw new InvalidOperationException();
            }
            if (music == null)
            {
                throw new ArgumentNullException("music");
            }
            SoundManager.Register(ClapSource.FilePath);
            SoundManager.Register(music.FilePath);
            EndTick = IsStopAtLastNote ? NoteView.Notes.GetLastTick() : GetTickFromTime(SoundManager.GetDuration(music.FilePath), NoteView.ScoreEvents.BPMChangeEvents);
            if (EndTick < startTick)
            {
                return(false);
            }

            var tickSet        = new HashSet <int>();
            var notes          = NoteView.Notes;
            var shortNotesTick = notes.Taps.Cast <TappableBase>().Concat(notes.ExTaps).Concat(notes.Flicks).Concat(notes.Damages).Select(p => p.Tick);
            var holdsTick      = notes.Holds.SelectMany(p => new int[] { p.StartTick, p.StartTick + p.Duration });
            var slidesTick     = notes.Slides.SelectMany(p => new int[] { p.StartTick }.Concat(p.StepNotes.Where(q => q.IsVisible).Select(q => q.Tick)));
            var airActionsTick = notes.AirActions.SelectMany(p => p.ActionNotes.Select(q => p.StartTick + q.Offset));

            foreach (int tick in shortNotesTick.Concat(holdsTick).Concat(slidesTick).Concat(airActionsTick))
            {
                tickSet.Add(tick);
            }
            TickElement = new LinkedList <int?>(tickSet.Where(p => p >= startTick).OrderBy(p => p).Select(p => new int?(p))).First;

            BPMElement = new LinkedList <BPMChangeEvent>(NoteView.ScoreEvents.BPMChangeEvents.OrderBy(p => p.Tick)).First;

            // スタート時まで進める
            while (TickElement != null && TickElement.Value < startTick)
            {
                TickElement = TickElement.Next;
            }
            while (BPMElement.Next != null && BPMElement.Next.Value.Tick <= startTick)
            {
                BPMElement = BPMElement.Next;
            }

            int clapLatencyTick = GetLatencyTick(ClapSource.Latency, (double)BPMElement.Value.BPM);

            InitialTick = startTick - clapLatencyTick;
            CurrentTick = InitialTick;
            StartTick   = startTick;

            TimeSpan startTime = GetTimeFromTick(startTick, NoteView.ScoreEvents.BPMChangeEvents);
            TimeSpan headGap   = TimeSpan.FromSeconds(-music.Latency) - startTime;

            elapsedTick = 0;
            Task.Run(() =>
            {
                LastSystemTick = Environment.TickCount;
                NoteView.Invoke((MethodInvoker)(() => Timer.Start()));

                System.Threading.Thread.Sleep(TimeSpan.FromSeconds(Math.Max(ClapSource.Latency, 0)));
                if (headGap.TotalSeconds > 0)
                {
                    System.Threading.Thread.Sleep(headGap);
                }
                if (!Playing)
                {
                    return;
                }
                SoundManager.Play(music.FilePath, startTime + TimeSpan.FromSeconds(music.Latency));
            })
            .ContinueWith(p =>
            {
                if (p.Exception != null)
                {
                    Program.DumpExceptionTo(p.Exception, "sound_exception.json");
                    ExceptionThrown?.Invoke(this, EventArgs.Empty);
                }
            });

            Playing = true;
            return(true);
        }
コード例 #29
0
ファイル: UpdateManager.cs プロジェクト: loLiK-CZ/realxaml
 private void WhenExceptionThrown(string message)
 {
     ExceptionThrown?.Invoke(this, new ExceptionNotificationEventArgs(message));
 }
コード例 #30
0
 public static void OnExceptionThrown(object sender, DndCoreExceptionEventArgs ea)
 {
     ExceptionThrown?.Invoke(sender, ea);
 }