.NET Based OPC UA Client/Server SDK  3.3.3.537
Manage Subscription – Delete Subscription

Prerequisites

A session and a subscription with the server must be established.

Description

The following dialog shows an example dialog to delete an existing subcription. Press the button “Show Code” to display the corresponding code, and the button “Help” to show this documentation page.

clienttutorials_delete_subscription.png

The state of the current subscription is shown in the field at “Subscription State”. At pressing the button “Delete”, the subscription and all of its monitored items are deleted. The field “Subscription State” now shows the status “Deleted”. Check the box in front of “Use Asynchronous Pattern” to call “BeginDelete” instead of “Delete”.

clienttutorials_delete_subscription2.png

Sample Code

The following code deletes an existing subscription and all of its monitored items.

try
{
// get the current session from the parent form.
Session session = m_parent.Session;
// nothing to do if no session.
if (session == null)
{
return;
}
// delete subscription (10s timeout).
m_subscription.Delete(new RequestSettings() { OperationTimeout = 10000 });
// up date display.
CurrentStateTB.Text = m_subscription.ConnectionStatus.ToString();
}
catch (Exception exception)
{
ExceptionDlg.ShowInnerException(this.Text, exception);
}
finally
{
Cursor = Cursors.Default;
}