Comments (2)
In one AT device, we have two thread. And it not good for so much device (ex: 100 devices).
So we can use 8-16 thread with SynchronizationContext for 100 devices
public void Open(SynchronizationContext synchronizationContext = null)
{
if (synchronizationContext != null)
{
reader = synchronizationContext.PostAsync(() => ReadPipeAsync(pipe, cancellationTokenSource.Token));
}
else
{
reader = Task.Factory.StartNew(() => AsyncContext.Run(() => ReadPipeAsync(pipe, cancellationTokenSource.Token)), TaskCreationOptions.LongRunning);
}
}
List<SynchronizationContext> _SynchronizationContextPool = new List<SynchronizationContext>();
async void MainLoopSynchronizationContextPool()
{
lock (_SynchronizationContextPool) _SynchronizationContextPool.Add(SynchronizationContext.Current);
while (true) await Task.Delay(10);
}
for (int i = 0; i < Environment.ProcessorCount; i++)
{
Task.Factory.StartNew(() => AsyncContext.Run(MainLoopSynchronizationContextPool), CancellationToken.None, TaskCreationOptions.LongRunning, TaskScheduler.Default);
}
await Task.Delay(1000);
for(int i = 0; devices.Count; i++)
{
//..........
atChannel.Open(_SynchronizationContextPool[ i % _SynchronizationContextPool.Count ]);
}
from atlib.
Thank you for reporting this and contributing to making this library better!
I've set it to use the thread pool: PR
from atlib.
Related Issues (17)
- Unhandled Exception HOT 4
- SIMCOM 7600 AT Commands HOT 1
- Stream WriteAsync Hang HOT 3
- How to make compatible with other brands HOT 2
- Record incomming call ???? HOT 2
- UCS2 encoding schema for arabic sms messages HOT 2
- International numbers HOT 3
- Support for Multi-part PDU? HOT 2
- Telit soft reset and set to factory profile feature request HOT 3
- Cannot send SMS with Telit xe910 modem in PDU mode using v7.0.0 HOT 4
- How can I send SMS with delivery report? HOT 1
- Supports for 4G commands
- Multiline Responses HOT 1
- Gsm7 Default encoding not reflecting LF/CR properly
- Sms Receiving
- How to make a phone Call? HOT 11
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from atlib.