Comments (2)
Please!, I need to help with this code, The worker services are different applications and they are installed in a raspberry pi as deamon services in Linux
I don´t know if on the code have fails or not, I was looking for information in Google but all that I found was useless and I didn´t work it.
Ticket Impress -> Program.cs
using ViewParking.Tickets.Raspberry.Impresion;
IHost host = Host.CreateDefaultBuilder(args)
.UseSystemd()
.ConfigureServices(services =>
{
services.AddSingleton<IHostedService, Worker>();
})
.Build();
await host.RunAsync();
Ticket Impress -> Worker.cs
namespace ViewParking.Tickets.Raspberry.Impresion;
public class Worker : BackgroundService
{
private readonly ILogger<Worker> _logger;
public Worker(ILogger<Worker> logger)
{
_logger = logger;
}
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
var configuration = new ConfigurationBuilder()
.AddJsonFile("appsettings.json", true, true)
.AddEnvironmentVariables()
.Build();
var properties = configuration.GetSection("Default");
var tiempoCicloChequeo = properties.GetValue<int>("TiempoCicloServicioMilisegundos");
var entrada = new EntradaImpresion();
Console.Clear();
while (!stoppingToken.IsCancellationRequested)
{
await Task.Delay(tiempoCicloChequeo, stoppingToken);
entrada.Iniciar();
}
}
}
Bill Impress -> Program.cs
using ViewParking.Facturas.Raspberry;
IHost host = Host.CreateDefaultBuilder(args)
.UseSystemd()
.ConfigureServices(services =>
{
services.AddSingleton<IHostedService, Worker>();
})
.Build();
await host.RunAsync();
Bill Impress -> Worker.cs
using ViewParking.Facturas.Raspberry.Impresion;
namespace ViewParking.Facturas.Raspberry
{
public class Worker : BackgroundService
{
private readonly ILogger<Worker> _logger;
public Worker(ILogger<Worker> logger)
{
_logger = logger;
}
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
var configuration = new ConfigurationBuilder()
.AddJsonFile("appsettings.json", true, true)
.AddEnvironmentVariables()
.Build();
var properties = configuration.GetSection("Default");
var tiempoCicloChequeo = properties.GetValue<int>("TiempoCicloServicioMilisegundos");
var entrada = new EntradaImpresion();
Console.Clear();
while (!stoppingToken.IsCancellationRequested)
{
await Task.Delay(tiempoCicloChequeo, stoppingToken);
entrada.Iniciar();
}
}
}
}
You response me, please!.
from esc-pos-.net.
Hi, that's too much information, and your code is not even presented with syntax highlight. Very hard to follow, especially with a lot of Spanish embedded in naming and all.
Anyhow, from what I could understand, you have 1 printer connected but 2 different apps running at the same time wishing to use the printer, but only the first application is able to do so, the second one is throwing an error. Is that it?
If that's the case, you have a race condition between your apps when consuming the printer resource. If you really wish to implement it like that (separate applications using the same printer) you would need a printing spooler, where you would have to manage the readiness of the printer, and most likely a printing queue, so there are no conflicts when trying to use it.
from esc-pos-.net.
Related Issues (20)
- Landscape Mode HOT 2
- Port get jammed after long use HOT 1
- Not getting status from SerialPrinter HOT 1
- Can't Print Greek characters HOT 2
- Windows and Linux support HOT 1
- HELP! My thermal printer printed out Chinese chars in some of ConsoleTest test HOT 3
- Error "Device or resourse busy" When I impress more the one time. HOT 5
- ESC-POS-.NET want work on MAUI Android - issue libSystem.IO.Ports.Native not loaded HOT 2
- Epson USB printer - getting "System.IO.IOException: The handle is invalid" HOT 2
- Is it possible to print in Page Mode ? (tickets with the exact same size) HOT 1
- is there Indian rupee sign ⟨₹⟩ in codepage? HOT 1
- PDF417 max 255 characters HOT 8
- Printer Stop before execution of cut command. HOT 2
- Other languages HOT 7
- Getting rid of the constant beeping when there is no paper in the paper feeder
- Problem with appPOS80AM3
- Problem with image and printer appPOSAM3 HOT 1
- Printer stopped sending status update events HOT 1
- Interest to support CUSTOM printers? HOT 2
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 esc-pos-.net.