日期:2014-05-19  浏览次数:20724 次

使用C#开发基于Compact Framework程序时遇到疑难问题!
我开发的设备是条码的扫描设备,厂家提供了一个SDK中有一个Reader类,我对这个类的包装如下:
        ///   <summary>
        ///   扫描类
        ///   </summary>
        public   class   BarcodeReader:IDisposable
        {
                public   Reader   reader   =   null;
                public   ReaderData   readerData   =   null;

                ///   <summary>
                ///   条码扫描完成后触发该事件
                ///   </summary>
                public   event   OnBarcodeOverHandler   OnBarcodeOver;

                public   BarcodeReader()
                {
                        if   (reader   ==   null)
                        {
                                reader   =   new   Reader();

                        }
                        if   (readerData   ==   null)
                        {
                                readerData   =   new   Symbol.Barcode.ReaderData(
Symbol.Barcode.ReaderDataTypes.Text,
Symbol.Barcode.ReaderDataLengths.MaximumLabel);
                        }
                        reader.ReadNotify   +=   new   EventHandler(reader_ReadNotify);
                        reader.Actions.Enable();
                        reader.Actions.Read(readerData);
                }


                private   void   reader_ReadNotify(object   sender,   EventArgs   e)
                {
                        if   (this.OnBarcodeOver   !=   null)
                        {
Symbol.Barcode.ReaderData   TheReaderData   =   this.reader.GetNextReaderData();
if   (TheReaderData.Result   ==   Symbol.Results.SUCCESS)
{
OnBarcodeOver(TheReaderData.Text);
}
                        }
reader.Actions.Read(readerData);//这个很关键,每次扫描成功后必需调用该方法才能使设备处于可扫描的状态.否则设备的