public void Logout() { try { NvrUserSession?.StopSession(); } catch (Exception e) { Console.WriteLine(e.Message + "\n" + e.StackTrace); } finally { NvrUserSession?.Dispose(); NvrUserSession = null; } }
public async Task LoginAsync(NvrSessionInfo sessionInfo) { string sdkLogDir = System.Reflection.Assembly.GetEntryAssembly().Location + @"_NvrSdkLogs\"; NvrUserSession = new NvrUserSession(sessionInfo, sdkLogDir, true); await Task.Factory.StartNew(() => { try { NvrUserSession.StartSession(); } catch (NvrSdkException ex) { throw new SystemException($"StartSession failed: NvrException Code[{ex.SdkErrorCode}]: {ex.Message}", ex); } catch (Exception ex) { throw new SystemException("StartSession failed: " + ex.Message, ex); } }, TaskCreationOptions.AttachedToParent); }