本文整理汇总了C#中Device.Close方法的典型用法代码示例。如果您正苦于以下问题:C# Device.Close方法的具体用法?C# Device.Close怎么用?C# Device.Close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Device
的用法示例。
在下文中一共展示了Device.Close方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
private static void Main(string[] args)
{
_acquisition = new Acquisition();
_acquisition.ImageAcquired += image_acquired;
_acquisition.AcquireCanceled += acquire_canceled;
_acquisition.AcquireFinished += acq_AcquireFinished;
_acquisition.AsynchronousException += acq_AsynchronousException;
_device = _acquisition.ShowSelectSource();
try
{
if (_device.TryOpen())
{
_device.AutoScan = true;
_device.HideInterface = true;
_device.ModalAcquire = false;
_device.DocumentFeeder.AutoFeed = true;
Console.WriteLine("Start Scanning Documents...");
_device.Acquire();
Console.Write("Press Enter when scanning is complete");
Console.ReadLine();
Console.WriteLine("Closing Scanner...");
_device.Close();
Console.WriteLine(" Closed");
}
}
catch (Exception exception)
{
Console.WriteLine(" -------Exception:-------");
Console.WriteLine(exception);
}
}
示例2: Start
/// <summary>
/// Starts processing GPS data from the specified stream.
/// </summary>
/// <param name="device">A device object providing GPS data to process.</param>
/// <remarks>This method will start the <strong>Interpreter</strong> using a separate thread.
/// The <strong>OnReadPacket</strong> is then called repeatedly from that thread to process
/// incoming data. The Pause, Resume and Stop methods are typically called after this
/// method to change the interpreter's behavior. Finally, a call to
/// <strong>Dispose</strong> will close the underlying stream, stop all processing, and
/// shut down the processing thread.</remarks>
public void Start(Device device)
{
// If we're disposed, complain
if (_isDisposed)
throw new ObjectDisposedException("The Interpreter cannot be started because it has been disposed.");
// Prevent state changes while the interpreter is started
#if !PocketPC
if (Monitor.TryEnter(SyncRoot, _commandTimeout))
#else
if (Monitor.TryEnter(SyncRoot))
#endif
{
try
{
// Set the device
_device = device;
// Signal that we're starting
OnStarting();
// If it's not open, open it now
if (!_device.IsOpen)
_device.Open();
// Indicate that we're running
_isRunning = true;
// Signal that the stream has changed
OnDeviceChanged();
// If the thread isn't alive, start it now
if (_parsingThread == null
#if !PocketPC
|| !_parsingThread.IsAlive
#else
|| !_IsParsingThreadAlive
#endif
)
{
_parsingThread = new Thread(ParsingThreadProc)
{
IsBackground = true,
Priority = _threadPriority,
Name = "GPS.NET Parsing Thread (http://dotspatial.codeplex.com)"
};
_parsingThread.Start();
// And signal the start
OnStarted();
}
else
{
// Otherwise, allow parsing to continue
_pausedWaitHandle.Set();
// Signal that we've resumed
OnResumed();
}
}
catch (Exception ex)
{
// Close the device
_device.Close();
// Show that we're stopped
OnStopped();
// Report the problem
throw new InvalidOperationException("The interpreter could not be started. " + ex.Message);
}
finally
{
// Release the lock
Monitor.Exit(SyncRoot);
}
}
else
{
// Signal a stop
OnStopped();
// The interpreter is already busy
throw new InvalidOperationException("The interpreter cannot be started. It appears that another thread is already trying to start, stop, pause, or resume.");
}
}