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(
int queueIndex,
out PcanMessage message,
out ulong timestamp
)
Public Function Dequeue (
queueIndex As Integer,
<OutAttribute> ByRef message As PcanMessage,
<OutAttribute> ByRef timestamp As ULong
) As Boolean
public:
bool Dequeue(
int queueIndex,
[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 second receive queue (index 1).
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.");
// Set the second filter (index 1) to pass all messages
//
myWorker.SetFilteringState(1, FilteringState.PassForAll);
// Wait for sometime to get messages in the receive queue
//
System.Threading.Thread.Sleep(5000);
PcanMessage message;
ulong timestamp;
if (myWorker.Dequeue(1, 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.")
' Set the second filter (index 1) to pass all messages
'
myWorker.SetFilteringState(1, FilteringState.PassForAll)
' 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(1, 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.");
// Set the second filter (index 1) to pass all messages
//
myWorker->SetFilteringState(1, FilteringState::PassForAll, false);
// Wait for sometime to get messages in the receive queue
//
System::Threading::Thread::Sleep(5000);
PcanMessage^ message;
UInt64 timestamp;
if (myWorker->Dequeue(1, 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);
}
IndexOutOfRangeException | The queueIndex parameter value is out of range. This must be in the range [0...ReceiveQueuesCount-1]. |