diff --git a/C#.NET/source/YitIdGen.WinFormApp/Program.cs b/C#.NET/source/YitIdGen.WinFormApp/Program.cs deleted file mode 100644 index 21301c5..0000000 --- a/C#.NET/source/YitIdGen.WinFormApp/Program.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using System.Windows.Forms; - -namespace WInFormApp -{ - static class Program - { - /// - /// The main entry point for the application. - /// - [STAThread] - static void Main() - { - Application.SetHighDpiMode(HighDpiMode.SystemAware); - Application.EnableVisualStyles(); - Application.SetCompatibleTextRenderingDefault(false); - Application.Run(new StartForm()); - } - } -} diff --git a/C#.NET/source/YitIdGen.WinFormApp/StartForm.Designer.cs b/C#.NET/source/YitIdGen.WinFormApp/StartForm.Designer.cs deleted file mode 100644 index 84e63f7..0000000 --- a/C#.NET/source/YitIdGen.WinFormApp/StartForm.Designer.cs +++ /dev/null @@ -1,90 +0,0 @@ - -namespace WInFormApp -{ - partial class StartForm - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.btnGen = new System.Windows.Forms.Button(); - this.txtIdList = new System.Windows.Forms.TextBox(); - this.button1 = new System.Windows.Forms.Button(); - this.SuspendLayout(); - // - // btnGen - // - this.btnGen.Location = new System.Drawing.Point(12, 385); - this.btnGen.Name = "btnGen"; - this.btnGen.Size = new System.Drawing.Size(170, 64); - this.btnGen.TabIndex = 0; - this.btnGen.Text = "注册"; - this.btnGen.UseVisualStyleBackColor = true; - this.btnGen.Click += new System.EventHandler(this.btnGen_Click); - // - // txtIdList - // - this.txtIdList.Location = new System.Drawing.Point(12, 12); - this.txtIdList.Multiline = true; - this.txtIdList.Name = "txtIdList"; - this.txtIdList.ScrollBars = System.Windows.Forms.ScrollBars.Both; - this.txtIdList.Size = new System.Drawing.Size(443, 346); - this.txtIdList.TabIndex = 1; - // - // button1 - // - this.button1.Location = new System.Drawing.Point(286, 385); - this.button1.Name = "button1"; - this.button1.Size = new System.Drawing.Size(170, 64); - this.button1.TabIndex = 2; - this.button1.Text = "注销"; - this.button1.UseVisualStyleBackColor = true; - this.button1.Click += new System.EventHandler(this.button1_Click); - // - // StartForm - // - this.AutoScaleDimensions = new System.Drawing.SizeF(11F, 24F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(468, 514); - this.Controls.Add(this.button1); - this.Controls.Add(this.txtIdList); - this.Controls.Add(this.btnGen); - this.Name = "StartForm"; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; - this.Text = "TestForm"; - this.Load += new System.EventHandler(this.Form1_Load); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.Button btnGen; - private System.Windows.Forms.TextBox txtIdList; - private System.Windows.Forms.Button button1; - } -} - diff --git a/C#.NET/source/YitIdGen.WinFormApp/StartForm.cs b/C#.NET/source/YitIdGen.WinFormApp/StartForm.cs deleted file mode 100644 index ac8b287..0000000 --- a/C#.NET/source/YitIdGen.WinFormApp/StartForm.cs +++ /dev/null @@ -1,86 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Runtime.InteropServices; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; - -namespace WInFormApp -{ - public partial class StartForm : Form - { - public StartForm() - { - InitializeComponent(); - } - - [DllImport("yitidgengo.dll", CallingConvention = CallingConvention.StdCall)] - public static extern long NextId(); - - [DllImport("yitidgengo.dll", CallingConvention = CallingConvention.StdCall)] - public static extern long NextId2(); - - [DllImport("yitidgengo.dll", CallingConvention = CallingConvention.StdCall)] - public static extern IntPtr RegisterMany(string ip, int port, string password, int maxWorkerIdNumber, int idCount); - //public static extern ulong RegisterWorkerId2(); - - [DllImport("yitidgengo.dll", CallingConvention = CallingConvention.StdCall)] - public static extern void UnRegister(); - - [DllImport("yitidgen.dll", CallingConvention = CallingConvention.StdCall)] - public static extern void SetWorkerId(uint workerId); - - [DllImport("yitidgen.dll", CallingConvention = CallingConvention.StdCall)] - public static extern int Test(); - - [DllImport("yitidgen.dll", CallingConvention = CallingConvention.StdCall)] - public static extern int GetWorkerId(string ip, int port); - - - private void Form1_Load(object sender, EventArgs e) - { - - } - - private void btnGen_Click(object sender, EventArgs e) - { - try - { - var ip = "localhost"; - - //txtIdList.Text += RegisterWorkerId(Encoding.UTF8.GetBytes(ip), 6379) + "\r\n"; - var ids = RegisterMany(ip, 6379, "", 4, 3); - //foreach (var id in ids) - //{ - // txtIdList.Text += id; - //} - - //txtIdList.Text += RegisterWorkerId() + "\r\n"; - - //txtIdList.Text += Test() + "\r\n"; - } - catch (Exception ex) - { - txtIdList.Text = ex.Message; - } - } - - private void button1_Click(object sender, EventArgs e) - { - try - { - UnRegister(); - txtIdList.Text += "LogOff"; - } - catch (Exception ex) - { - txtIdList.Text = ex.Message; - } - // GetWorkerId("localhost", 6379); - } - } -} diff --git a/C#.NET/source/YitIdGen.WinFormApp/StartForm.resx b/C#.NET/source/YitIdGen.WinFormApp/StartForm.resx deleted file mode 100644 index b5ae26c..0000000 --- a/C#.NET/source/YitIdGen.WinFormApp/StartForm.resx +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/C#.NET/source/YitIdGen.WinFormApp/YitIdGen.WinFormApp.csproj b/C#.NET/source/YitIdGen.WinFormApp/YitIdGen.WinFormApp.csproj deleted file mode 100644 index 2bbc716..0000000 --- a/C#.NET/source/YitIdGen.WinFormApp/YitIdGen.WinFormApp.csproj +++ /dev/null @@ -1,19 +0,0 @@ - - - - WinExe - net5.0-windows - true - - - - - - - - - PreserveNewest - - - - \ No newline at end of file diff --git a/C#.NET/source/YitIdGen.WinFormApp/yitidgen.dll b/C#.NET/source/YitIdGen.WinFormApp/yitidgen.dll deleted file mode 100644 index b3b9a92..0000000 Binary files a/C#.NET/source/YitIdGen.WinFormApp/yitidgen.dll and /dev/null differ diff --git a/C#.NET/source/Yitter.IdGen.sln b/C#.NET/source/Yitter.IdGen.sln index 2daaa91..2cbc6ea 100644 --- a/C#.NET/source/Yitter.IdGen.sln +++ b/C#.NET/source/Yitter.IdGen.sln @@ -7,8 +7,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Yitter.IdGenerator", "Yitte EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Yitter.IdGenTest", "Yitter.IdGenTest\Yitter.IdGenTest.csproj", "{67426F7D-0A3B-4645-B4D7-5487215D3E2B}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "YitIdGen.WinFormApp", "YitIdGen.WinFormApp\YitIdGen.WinFormApp.csproj", "{1035D82E-3F37-4940-AA32-5D1E0E53AFA5}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -23,10 +21,6 @@ Global {67426F7D-0A3B-4645-B4D7-5487215D3E2B}.Debug|Any CPU.Build.0 = Debug|Any CPU {67426F7D-0A3B-4645-B4D7-5487215D3E2B}.Release|Any CPU.ActiveCfg = Release|Any CPU {67426F7D-0A3B-4645-B4D7-5487215D3E2B}.Release|Any CPU.Build.0 = Release|Any CPU - {1035D82E-3F37-4940-AA32-5D1E0E53AFA5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {1035D82E-3F37-4940-AA32-5D1E0E53AFA5}.Debug|Any CPU.Build.0 = Debug|Any CPU - {1035D82E-3F37-4940-AA32-5D1E0E53AFA5}.Release|Any CPU.ActiveCfg = Release|Any CPU - {1035D82E-3F37-4940-AA32-5D1E0E53AFA5}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/C#.NET/source/Yitter.IdGenTest/Program.cs b/C#.NET/source/Yitter.IdGenTest/Program.cs index c389276..519a228 100644 --- a/C#.NET/source/Yitter.IdGenTest/Program.cs +++ b/C#.NET/source/Yitter.IdGenTest/Program.cs @@ -24,22 +24,6 @@ namespace Yitter.OrgSystem.TestA static int workerCount = 1; - //[DllImport("yitidgenc.dll", CallingConvention = CallingConvention.StdCall)] - //public static extern long NextId(); - - [DllImport("yitidgengo.dll", EntryPoint = "NextId", CallingConvention = CallingConvention.StdCall)] - public static extern long NextId2(); - - [DllImport("yitidgengo.so", EntryPoint = "NextId", CallingConvention = CallingConvention.StdCall)] - public static extern long NextId(); - - [DllImport("yitidgen.dll", CallingConvention = CallingConvention.StdCall)] - public static extern void SetWorkerId(uint workerId); - - [DllImport("yitidgen.dll", CallingConvention = CallingConvention.StdCall)] - public static extern int TestId(); - - static void Main(string[] args) { Console.WriteLine("Hello World! C#"); @@ -77,46 +61,6 @@ namespace Yitter.OrgSystem.TestA } } - - private static void CallDll() - { - try - { - int i = 0; - long id = 0; - DateTime start = DateTime.Now; - bool useMultiThread = false; - - //var ids = TestId(); - //SetWorkerId(1); - - while (i < 50000) - { - i++; - - if (useMultiThread) - { - Task.Run(() => - { - id = NextId(); - Console.WriteLine("id:" + id); - }); - } - else - { - id = NextId(); - } - } - DateTime end = DateTime.Now; - Console.WriteLine("id:" + id); - Console.WriteLine($"+++++++++++C# call rust dll, gen 5W, total: {(end - start).TotalMilliseconds} ms"); - } - catch (Exception ex) - { - Console.WriteLine(ex.Message); - } - } - private static void RunSingle() { DateTime start = DateTime.Now;