Cash drawer with receipt printer slow performance with thrading RRS feed

  • Question

  • Hi all,

    I'm using POS for .net for my application for receipt printer , cash drawer , Line Display.Now i'm having some performance issue when i use receipt printer with cash drawer.For a example When cash drawer is open there should be receipt printing saying "drawer  open" , if this 2 task happen same time ,some times entire application get stuck or printer will print receipt by delaying around 5 seconds.I've tried with most scenarios like cash drawer opens first and recept printer print subsequently and print first then open drawer secondly .but both having slow performance.These are my suspect areas..

    **** Cash drawer is connect to the system through the receipt printer , if i'm doing only the print part there is no delay or any issue.if there is some dependency on this.

    This is my code for open cash drawer

     PosExplorer posExplorer = new PosExplorer();
                    DeviceInfo CashDrawerDevice = posExplorer.GetDevice(DeviceType.CashDrawer, clsUtility.CashDrawerLogicalName); //May need to change this if you don't use a logicial name or use a different one.
                    if(CashDrawerDevice != null)
                        Drawer = (CashDrawer)posExplorer.CreateInstance(CashDrawerDevice);
    if (!Drawer.DrawerOpened)
        Drawer.DeviceEnabled = true;
        Drawer.DeviceEnabled = false;

    ** All these steps runs under new thread , like

    Thread PrintThread = new Thread(new ThreadStart(PrintReceipt));

    Is this will be the problem ?

    I've noticed that OpenDrawer() method and Close() method is getting more time to execute like 4-5 seconds.

    Please help us to solve this issue with ur ideas..

    Thanks & Regards,


    Monday, January 21, 2013 3:43 AM

All replies

  • Dont have the hardware or such to really test this but two things you can try:

    • if both run in same thread and calling print and open drawer in sync would do what you want?
    • create a static object and use it as a lock before each function (in both operations) before calls to long lasting operations.

    Anze Javornik

    Tuesday, January 22, 2013 1:50 AM
  • Hi Dimuthu,

    Welcome to the MSDN Forum.

    I am trying to involve some other one into this case, it would take some times, wait it patiently, please.

    Thank you.

    Best regards,

    Mike Feng
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, January 22, 2013 2:10 AM
  • I found a similar issue when developing my cash register application for my book. What I did was open-claimed-open cash drawer-release-close the cash drawer and the did the open-claim-print-release-close the cash drawer. Having both devices opened and claimed at the same time since they are on the same port can cause issues.


    www.annabooks.com / www.seanliming.com / Book Author - Pro Guide to WES 7, XP Embedded Advanced, Pro Guide to POS for .NET

    Tuesday, January 22, 2013 5:19 PM
  • Hi Dimuthu,

    Offhand, it sounds very much something like Sean was mentioning, where perhaps multiple devices are contending for the same resource. You may have to experiment with the same sort of pattern as Sean suggests. Otherwise, have you tried either profiling the "slow" part of the operation and/or attached a debugger to see what was going on at the time? I suspect you will see time being spent in the service object you're using and/or with the kernel doing device I/O.

    Hope this helps,

    Keith Fink [MSFT]

    Keith Fink Microsoft

    Thursday, January 24, 2013 4:18 PM
  • Hi ,

    Thx for ur suggetions , i tried with many ways/combinations except creating static object , i'll try to do this as well but the problem is i'm initialize & connect printer and cash drawer within the class constructor.So far with many trys now i'can do some thing for this , now if i print 1st and eject the cash drawer 2nd there is no delay . but this is not i need.when i eject the cash drawer 1st and print as 2nd step there is about 5-10 secs delay occurs.I've remove the threding part and try but there is no effect using thread. do u guys have any ideas on this..

    Thanks & Regards,


    Monday, January 28, 2013 2:00 AM
  • Without more information, such as the call stacks of the relevant threads when you reproduce the problem, or running under a profiler, I couldn't really speculate. I suspect the issue may be to do either with how your threading code is architected or possibly something with the OPOS service objects driving the devices you're talking to. If you use the debugger to break into the application when it is delayed, you should be able to see what code path it is in and that might give you a better idea of how to resolve this.

    Hope that helps,

    Keith Fink [MSFT]

    Keith Fink Microsoft

    Monday, January 28, 2013 9:53 PM