diff --git a/ntfysh_client/NotificationListener.cs b/ntfysh_client/NotificationListener.cs index 408c274..385e244 100644 --- a/ntfysh_client/NotificationListener.cs +++ b/ntfysh_client/NotificationListener.cs @@ -20,7 +20,7 @@ namespace ntfysh_client private readonly HttpClient _httpClient = new(); private bool _isDisposed; - public readonly Dictionary SubscribedTopicsByUnique = new(); + public readonly Dictionary SubscribedTopicsByUnique = new(); public delegate void NotificationReceiveHandler(object sender, NotificationReceiveEventArgs e); public event NotificationReceiveHandler? OnNotificationReceive; @@ -37,8 +37,8 @@ namespace ntfysh_client while (!cancellationToken.IsCancellationRequested) { - using HttpResponseMessage response = await _httpClient.SendAsync(message, HttpCompletionOption.ResponseHeadersRead, cancellationToken); - using Stream body = await response.Content.ReadAsStreamAsync(); + using HttpResponseMessage response = await _httpClient.SendAsync(message, HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false); + await using Stream body = await response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false); try { @@ -48,7 +48,7 @@ namespace ntfysh_client { //Read as much as possible byte[] buffer = new byte[8192]; - int readBytes = await body.ReadAsync(buffer, 0, buffer.Length, cancellationToken); + int readBytes = await body.ReadAsync(buffer, 0, buffer.Length, cancellationToken).ConfigureAwait(false); //Append it to our main buffer mainBuffer.Append(Encoding.UTF8.GetString(buffer, 0, readBytes)); @@ -134,16 +134,16 @@ namespace ntfysh_client #endif //Topic isn't even subscribed, ignore - if (!SubscribedTopicsByUnique.TryGetValue(topicUniqueString, out SubscribedTopic topic)) return; + if (!SubscribedTopicsByUnique.TryGetValue(topicUniqueString, out SubscribedTopic? topic)) return; //Cancel and dispose the task runner - topic.RunnerCanceller.Cancel(); + topic?.RunnerCanceller.Cancel(); //Wait for the task runner to shut down - while (!topic.Runner.IsCompleted) Thread.Sleep(100); + while (topic is not null && !topic.Runner.IsCompleted) Thread.Sleep(100); //Dispose task - topic.Runner.Dispose(); + topic?.Runner.Dispose(); //Remove the old topic SubscribedTopicsByUnique.Remove(topicUniqueString); diff --git a/ntfysh_client/Program.cs b/ntfysh_client/Program.cs index a980f95..6f47948 100644 --- a/ntfysh_client/Program.cs +++ b/ntfysh_client/Program.cs @@ -16,6 +16,7 @@ namespace ntfysh_client [STAThread] static void Main() { + //Application.SetHighDpiMode(HighDpiMode.SystemAware); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1(NotificationListener)); diff --git a/ntfysh_client/Properties/AssemblyInfo.cs b/ntfysh_client/Properties/AssemblyInfo.cs deleted file mode 100644 index 07fb348..0000000 --- a/ntfysh_client/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("ntfy.sh")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("ntfy.sh")] -[assembly: AssemblyCopyright("Copyright © 2022")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("5a18d152-d620-43fe-b844-def30cfa50ef")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/ntfysh_client/Properties/Resources.Designer.cs b/ntfysh_client/Properties/Resources.Designer.cs deleted file mode 100644 index 8cf2c22..0000000 --- a/ntfysh_client/Properties/Resources.Designer.cs +++ /dev/null @@ -1,63 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace ntfysh_client.Properties { - using System; - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Resources { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Resources() { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ntfysh_client.Properties.Resources", typeof(Resources).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - } -} diff --git a/ntfysh_client/Properties/Resources.resx b/ntfysh_client/Properties/Resources.resx deleted file mode 100644 index af7dbeb..0000000 --- a/ntfysh_client/Properties/Resources.resx +++ /dev/null @@ -1,117 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/ntfysh_client/Properties/Settings.Designer.cs b/ntfysh_client/Properties/Settings.Designer.cs deleted file mode 100644 index 67b3c60..0000000 --- a/ntfysh_client/Properties/Settings.Designer.cs +++ /dev/null @@ -1,26 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace ntfysh_client.Properties { - - - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.10.0.0")] - internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { - - private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); - - public static Settings Default { - get { - return defaultInstance; - } - } - } -} diff --git a/ntfysh_client/Properties/Settings.settings b/ntfysh_client/Properties/Settings.settings deleted file mode 100644 index 3964565..0000000 --- a/ntfysh_client/Properties/Settings.settings +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/ntfysh_client/ntfysh_client.csproj b/ntfysh_client/ntfysh_client.csproj index 3708738..dfe4310 100644 --- a/ntfysh_client/ntfysh_client.csproj +++ b/ntfysh_client/ntfysh_client.csproj @@ -1,119 +1,20 @@ - - - + + - Debug - AnyCPU - {5A18D152-D620-43FE-B844-DEF30CFA50EF} WinExe - ntfysh_client - ntfysh - v4.7.2 - 512 - true - true + net6.0-windows + true latest enable - - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - NotificationHub.ico + - - ..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll - - - - - - - - - - - - - + + - - Form - - - AboutBox.cs - - - Form - - - Form1.cs - - - - - - - - Form - - - SubscribeDialog.cs - - - - AboutBox.cs - - - Form1.cs - - - ResXFileCodeGenerator - Resources.Designer.cs - Designer - - - True - Resources.resx - True - - - SubscribeDialog.cs - - - - SettingsSingleFileGenerator - Settings.Designer.cs - - - True - Settings.settings - True - + - - - - - - - + \ No newline at end of file