auto commit
This commit is contained in:
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
Application.SetHighDpiMode(HighDpiMode.SystemAware);
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
Application.Run(new StartForm());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,90 +0,0 @@
|
||||
|
||||
namespace WInFormApp
|
||||
{
|
||||
partial class StartForm
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
<root>
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
@@ -1,19 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net5.0-windows</TargetFramework>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove="yitidgen.dll" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="yitidgen.dll">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
Binary file not shown.
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user