Home > Net >  Designed for c # personnel encapsulation kernel-level thread pool, hardware operation more easy and
Designed for c # personnel encapsulation kernel-level thread pool, hardware operation more easy and

Time:09-20

Abandon your timer component, overlapping the direct use of kernel level IO develop your hardware, and you can use the thread pool design more ideas, the encapsulation is limited to technical communication

Link: https://pan.baidu.com/s/1BNZI5EOG1LaYWcgj_UGIpg
The extracted code: ZJNW

CodePudding user response:

The Thread pool for a Task and directly using Thread ThreadPool advantage

CodePudding user response:

So big, why not throw to the git, lets everybody directly judged,

CodePudding user response:

You to test to know, where is the specific advantage your test

CodePudding user response:

I hope you can provide a BUG for me to modify

CodePudding user response:

Making on open please, if difficult here, at least also code on cloud
Baidu network backup source really inappropriate

CodePudding user response:

Inside the zip code, documentation,

CodePudding user response:

What this for??

CodePudding user response:

Is the way I opened the wrong? I download prompt a compressed packet error several times.

Another really consider 1 # is.. Since you can write good things.. Has to have at least a few words of introduction.

Advantage?

CodePudding user response:

1. I down after the program compiled but
2. You said the operation is simple and c # native threads model Thread ThreadPool Task compare your strengths rather than allow ourselves to feel because most people with the above three kinds of already very skilled amount
(3) is to provide a better use the sample point

CodePudding user response:

And I am using VS2013

CodePudding user response:

Visual studio 2017 compiled for X64 and X86 cannot use anycpu platform, the thread pool is used kernel-level threads, thread is not using c #, IO model using IOCP model design, fine in serial operation, in addition, in the use of the thread pool won't worry about the schedule, the resource scheduling is assigned by the kernel of intelligent,

CodePudding user response:

The.net version 4.5.2 or above,

CodePudding user response:

I don't know what to do with

CodePudding user response:

Directly on the lot, perhaps is fire

CodePudding user response:

It's so useful! Wow!!!!

CodePudding user response:

Why don't you put a git?

CodePudding user response:

11 references weixin_35107932 response:
visual studio 2017 compiled for X64 and X86 cannot use anycpu platform, the thread pool is used kernel-level threads, thread is not using c #, IO model using IOCP model design, the serial port operation performance outstanding, in addition, in the use of the thread pool won't worry about the schedule, the resource scheduling is assigned by the kernel intelligent,

C # using the thread is not a kernel level? About serial port function IOCP model it's a waste, a serial port traffic is not too big,

CodePudding user response:

Kernel level?? It is much,,

CodePudding user response:

CodePudding user response:

Very good,
But given the difference between kernel level and user-level threads
It is favourable,

CodePudding user response:

Kernel level?? It is much,,

CodePudding user response:

Learning, thank you, thank you

CodePudding user response:

Hengaoxing it's nice to be here

CodePudding user response:

Hope everybody many test, and feedback to my BUG, let me continue to optimize, the mailbox 159430177 @qq.com

CodePudding user response:

Attach a simple Socket server, using the thread pool do after the test, 5000 concurrent connections CPU resources still remain below 8.2%, more substantial,

Class Program
{
The static void Main (string [] args)
{
ThreadPool ThreadPool=new ThreadPool ();
ThreadPool. AdjustWorkMode (ThreadPoolMode. EFFICIENT);

The Socket server=new Socket (AddressFamily. InterNetwork, SocketType Stream, ProtocolType. Tcp);
Server. The Bind (new IPEndPoint (IPAddress. Any, 15000));
Server. Listen (100);
While (true)
{
The Socket client=server. The Accept ();
Var workerobj=new MyClass (the client);
The Worker Worker=threadPool. CreateWorker (WorkerType XR_TP_TYPE_ASYNC, workerobj, null);
ThreadPool. SubmitWorker (worker, null);
}
}
}


The class MyClass: IAsyncContext
{
Private Socket client;
Private bool isread;

Public MyClass (Socket client)
{
This. Client=client;
}
Public Boolean Before (IntPtr instance, IntPtr work)
{
Console. WriteLine (" the client: "+ client. RemoteEndPoint +" is connected!" );
return true;
}

Public Boolean Process (IntPtr instance, IntPtr work)
{
Try
{
Int length=client. The Available;
Byte [] buffer=new byte (length),
Int r=client. The Receive buffer, length, SocketFlags. None);

If (r==0 & amp; & Isread)
{
Client. Shutdown (SocketShutdown. Both);
Console. WriteLine (" the client: "+ client. RemoteEndPoint +" is disconnected!" );
return true;
}

If (r==0 & amp; & ! Isread)
{
Isread=client. Poll (100, SelectMode. SelectRead);
}

If (r & gt; 0)
{
Isread=false;
//TODO receives the data and processing
String resutl.=Encoding UTF8. Get string (buffer);
Console. WriteLine (resutl);
}
The Process (the instance, the work);
}
The catch (Exception e)
{
Client. Shutdown (SocketShutdown. Both);
}
return true;
}

Public void After (IntPtr instance, IntPtr work)
{
Console. WriteLine (" the client "+ client. RemoteEndPoint +" is disconnected!" );
}

}

CodePudding user response:

May be a good thing, but the framework version is too high.

CodePudding user response:

Good thing!!!!!!!!!!

CodePudding user response:

nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  •  Tags:  
  • C#
  • Related