Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 450933
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T21:55:06+00:00 2026-05-12T21:55:06+00:00

I am printing to a thermal ticket printer which has no standard drivers. Traditionally

  • 0

I am printing to a thermal ticket printer which has no standard drivers. Traditionally our business process has been to produce a batch file of print items and to deliver that through an open socket to the printer. When the program has finished processing and prior to tidying up by shutting the socket I blocked the process by popping up a MessageBox with a warning to the user not to press OK until printing had finished: the next line of code then forcibly closed and cleared away the socket.

It was a bit of a sticky tape and string solution but it served its purpose.

I’ve recently overhauled the printing process using WCF Webservices and LINQ data management. As a result the batch files have become less necessary (they’re still useful in the case of printing or reprinting for customers because the batchfile forms a sort of “receipt” to say that the physical ticket exists). But the old “stuff up a messagebox” solution to telling people when it’s safe to close the socket looks unacceptably creaky in this new program.

So I want to have it just finish using the socket, exit gracefully and then pop up the box to say that printing is finished. Having a quick look around at possible solutions to this problem I have come across:

  • The idea of using a separate thread for the printing process
  • The idea of asynchronous sockets
  • A method called Socket.Shutdown

What I’d really like is an overview of advantages/disadvantages of these three approaches.

Our usage scenario is that we seldom need use of a “queue” as the ticket printer isn’t used anywhere near as heavily as a regular office printer. The printing of a batch of customer tickets or of 300 tickets for sale over the counter at a venue is still an event there aren’t really disputes about who wants to do what and when. Even at one of our client sites where there are enough people that usage of the printer could cause conflicts the printer is usually closely monitored as it does its work.

This is, of course, because the minute a ticket comes out of the printer it has a monetary worth. As soon as the tickets are printed they tend to be taken away to be securely stored.

So bearing in mind this business process I want something unfussy that needn’t worry overmuch about simultaneous requests.

EDIT: I did a bunch of research and tried different things on this. In this particular scenario the fact that the print socket blocks the UI thread is not a problem. People don’t want to continue using the UI whilst the valuable stream of tickets streams out of the printer. But after looking at the way ASync requests work it seemed more logical given the most likely usage scenario to open the socket when the print options page opened and close it as it exited. The Async tutorials I did indicated that this is pretty much how things would work anyway.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T21:55:06+00:00Added an answer on May 12, 2026 at 9:55 pm
    • The idea of using a separate thread for the printing process:
      In this case you’re still using sockets synchronously i presume. Which means you’re still blocking the thread when awaiting a response. Which isn’t a problem in a seperate thread, but performance wise it still isn’t the way to go.

    • The idea of asynchronous sockets:
      Is the standard way to use a socket when you don’t want to block your current thread. This doesn’t do any blocking operations which means better performance. The disadvantage is maybe that synchronous code looks a bit more clear and is easier to use. I would go with this one.

    • A method called Socket.Shutdown: This isn’t a solution to your problem. It is a way to disable sending and receiving on a socket. It is best practice to shutdown the socket before closing it.
      For example in C#:

      socket.Shutdown(SocketShutdown.Both);
      socket.Close();

    Remember though when closing your application that you should wait until all backgound threads have been finished before actually letting the application close.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.