From: Olexandr Kravets on
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace MultiScanForm
{
public partial class SecondChildForm : Form
{
public SecondChildForm(string label)
{
InitializeComponent();
textBox1.Text = label;
}

private void button1_Click(object sender, EventArgs e)
{
Close();
}
}
}
From: Olexandr Kravets on
//--------------------------------------------------------------------
// FILENAME: Scanning.cs
//
// Copyright(c) 2005 Symbol Technologies Inc. All rights reserved.
//
// DESCRIPTION:
//
// NOTES:
//
//
//--------------------------------------------------------------------
using System;
using System.Diagnostics;

namespace MultiScanForm
{
/// <summary>
/// The Scanning class provides static methods to allow reuse of the same
/// Reader and ReaderData objects on multiple forms.
/// </summary>
public class Scanning
{
private static Symbol.Barcode.Reader _MyReader = null;
private static Symbol.Barcode.ReaderData _MyReaderData = null;
private static System.EventHandler _MyEventHandler = null;

/// <summary>
/// MyReaderData property provides access to the ReaderData
/// </summary>
public static Symbol.Barcode.ReaderData MyReaderData
{
get { return _MyReader.GetNextReaderData(); }
}

/// <summary>
/// Upon completion of a scan a ReadNotify event will be fired.
/// _MyEventHandler specifies the delegate that will handle this
notification
/// and MyEventHandler property provides access to _MyEventHandler.
/// Each form that uses the Scanning class will have it's own delegate.
/// The form will be responsible for setting this Event Handler to it's
delegate.
/// </summary>
public static System.EventHandler MyEventHandler
{
get { return _MyEventHandler; }
set { _MyEventHandler = value; }
}

/// <summary>
/// Initialize the reader.
/// </summary>
public static bool InitReader()
{
// If reader is already present then fail initialize
if ( Scanning._MyReader != null )
{
return false;
}
Debug.WriteLine("InitReader");

// Create new reader, first available reader will be used.
Scanning._MyReader = new Symbol.Barcode.Reader();

// Create reader data
Scanning._MyReaderData = new Symbol.Barcode.ReaderData(
Symbol.Barcode.ReaderDataTypes.Text,
Symbol.Barcode.ReaderDataLengths.MaximumLabel);

// Enable reader, with wait cursor
Scanning._MyReader.Actions.Enable();

Scanning._MyReader.Parameters.Feedback.Success.BeepTime = 0;
Scanning._MyReader.Parameters.Feedback.Success.WaveFile =
"\\windows\\alarm3.wav";

return true;
}

/// <summary>
/// Stop reading and disable/close reader
/// </summary>
public static void TermReader()
{
Debug.WriteLine("TermReader");
// If we have a reader
if ( Scanning._MyReader != null )
{
// Disable the reader
Scanning._MyReader.Actions.Disable();

// Free it up
Scanning._MyReader.Dispose();

// Indicate we no longer have one
Scanning._MyReader = null;
}

// If we have a reader data
if ( Scanning._MyReaderData != null )
{
// Free it up
Scanning._MyReaderData.Dispose();

// Indicate we no longer have one
Scanning._MyReaderData = null;
}
}

/// <summary>
/// Start a read on the reader
/// </summary>
public static void StartRead(string form)
{
// If we have both a reader and a reader data
if ( ( Scanning._MyReader != null ) &&
( Scanning._MyReaderData != null ) )
{
Debug.WriteLine(string.Format("StartRead <{0}>",form));
// Submit a read
Scanning._MyReader.ReadNotify += Scanning._MyEventHandler;

// Prevent duplicate reads
if ( !Scanning._MyReaderData.IsPending )
Scanning._MyReader.Actions.Read(Scanning._MyReaderData);
}
}

/// <summary>
/// Stop all reads on the reader
/// </summary>
public static void StopRead(string form)
{
// If we have a reader
if ( Scanning._MyReader != null )
{
Debug.WriteLine(string.Format("StopRead <{0}>",form));
// Flush (Cancel all pending reads)
Scanning._MyReader.ReadNotify -= Scanning._MyEventHandler;
Scanning._MyReader.Actions.Flush();
}
}
public static void ToggleTrigger()
{
if (Scanning._MyReader== null)
{
return;
}
Scanning._MyReader.Actions.ToggleSoftTrigger();
}

}
}

From: savvaschr on

Try to Contact www.Symbol.com , They help me a lot with MC70,
Also check your OEM version of the MC70 cause they have upgrades.

From: Olexandr Kravets on
Hi !
Finally, I figured out how to make it work. I just changed handler of scan
to invoke my another handler async. I set ScannedEvent before.

private void MyReader_ReadNotify(object sender, EventArgs e)
{
if (BarcodeReader.MyReaderData.Result == Symbol.Results.SUCCESS)
{
ScanEventArgs scanArgs = new
ScanEventArgs(BarcodeReader.MyReaderData.Text);
form.BeginInvoke(this.ScannedEvent, this, scanArgs);
this.StartRead();
}
}

Thanks, Sasha !

From: Martin on
create static class for symbol scanner
and use this in all foms
open scanner at startup, activae / deactivae only during open/close forms,
shutdown during application close