Note
On Windows, the timestamp contains the number of microseconds elapsed since system start.
On Linux, the timestamp contains the number of microseconds elapsed since the epoch (00:00 UTC, January 1st 1970).
public bool Dequeue(
out PcanMessage message,
out ulong timestamp
)
Public Function Dequeue (
<OutAttribute> ByRef message As PcanMessage,
<OutAttribute> ByRef timestamp As ULong
) As Boolean
public:
bool Dequeue(
[OutAttribute] PcanMessage^% message,
[OutAttribute] unsigned long long% timestamp
)
This implies, that an application can keep processing messages after a connection to a PCAN Channel has been terminated.
The following example shows how to retrieve a message from the default receive queue (index 0).
In case of failure, an error messages is written to the console output using English as output language.
// Create the object using the default configuration
//
Worker myWorker = new Worker();
try
{
// Activate the worker object
//
myWorker.Start();
Console.WriteLine("The Worker object was activated successfully.");
// Wait for sometime to get messages in the receive queue
//
System.Threading.Thread.Sleep(5000);
PcanMessage message;
ulong timestamp;
if (myWorker.Dequeue(out message, out timestamp))
{
Console.WriteLine("New message retrieved. ");
Console.WriteLine($"Timestamp: {timestamp} | {message}");
}
// Deactivate the worker object, when it is no longer needed
//
myWorker.Stop();
Console.WriteLine("The Worker object was deactivated.");
}
catch(Exception ex)
{
Console.WriteLine($"An exception occurred by activating the Worker object. {ex.Message}");
}
' Create the object using the default configuration
'
Dim myWorker As Worker = New Worker()
Try
' Activate the worker object
'
myWorker.Start()
Console.WriteLine("The Worker object was activated successfully.")
' Wait for sometime to get messages in the receive queue
'
Threading.Thread.Sleep(5000)
Dim message As PcanMessage = Nothing
Dim timestamp As ULong
If myWorker.Dequeue(message, timestamp) Then
Console.WriteLine("New message retrieved. ")
Console.WriteLine($"Timestamp: {timestamp} | {message}")
End If
' Deactivate the worker object, when it is no longer needed
'
myWorker.[Stop]()
Console.WriteLine("The Worker object was deactivated.")
Catch ex As Exception
Console.WriteLine($"An exception occurred by activating the Worker object. {ex.Message}")
End Try
// Create the object using the default configuration
//
Worker^ myWorker = gcnew Worker();
try
{
// Activate the worker object
//
myWorker->Start(false, false, false);
Console::WriteLine("The Worker object was activated successfully.");
// Wait for sometime to get messages in the receive queue
//
System::Threading::Thread::Sleep(5000);
PcanMessage^ message;
UInt64 timestamp;
if (myWorker->Dequeue(message, timestamp))
{
Console::WriteLine("New message retrieved. ");
Console::WriteLine("Timestamp: {0} | {1}", timestamp, message);
}
// Deactivate the worker object, when it is no longer needed
//
myWorker->Stop(false, false, false);
Console::WriteLine("The Worker object was deactivated.");
}
catch (Exception^ ex)
{
Console::WriteLine("An exception occurred by activating the Worker object. {0}", ex->Message);
}