NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Testing App, Sending C# Notifications to TestStand, working but cannot close cleanly

Hi

 

I have a very small C# windows form app that I am using to send Notification messages to a Test Stand Sequence, using the Sync Manager. My starting point was 

 

https://forums.ni.com/t5/Example-Code/TestStand-Notification-Cross-Process-Example-in-C/ta-p/3961781... 

 

This is working fine for sending both Set and Pulse Notifications and my tiny Application closes fine.

 

I am now trying to send a numeric value with my Notification.  I have got this working the correct value is being seen in TestStand Sequence but I my Application will not close correctly as I cannot release the PropertyObject that I use to send the value with and so the engine will not close down.

 

private static INotification NewChamberIntervalRef { get; set; }
private static Engine myEngine;
private PropertyObject newInterval;
private SyncManager mySyncManager;

 

public TestStationControl()
{
    InitializeComponent();

    //Creating a notifier with name *myNotification. *SyncObjects can be shared across processes
    // we are NOT launching this engine is a new Application Domain as recommended, because we need
    // direct access for notifier plus this is the ONLY function for this engine.
    myEngine = new Engine();
    newInterval = myEngine.NewPropertyObject(PropertyValueTypes.PropValType_Number, false, "", 0);

    mySyncManager = myEngine.GetSyncManager("64*NewChamberInterval") as SyncManager;

   bool alreadyexists = false;
   NewChamberIntervalRef = mySyncManager.CreateNotification("64*NewChamberInterval", out alreadyexists);
}

 

 

private void Start_button_Click(object sender, EventArgs e)
{

    //Setting the Notification
    newInterval.SetValNumber("", 0,(int)intervalNum.Value);
    NewChamberIntervalRef.PulseEx(null, newInterval , true, true);
}

 

private void TestStationControl_FormClosing(object sender, FormClosingEventArgs e)
{
    // we need to release everything then close the TestStand Engine
    myEngine.DotNetGarbageCollectionInterval = 100;
    newInterval = null;
    mySyncManager = null;
    myEngine = null;
}

 

 

 

Danny Thomson AshVire Ltd
0 Kudos
Message 1 of 3
(956 Views)

Have you seen this?

 
Having new app domain might help to force garbage collection and therefore make clean shutdown possible.
Michał Bieńkowski
CLA, CTA

Someone devote his time to help solve your problem? Appreciate it and give kudos. Problem solved? Accept as a solution so that others can find it faster in the future.
Make a contribution to the development of TestStand - vote on TestStand Idea Exchange.
0 Kudos
Message 2 of 3
(879 Views)

Hi Michal,

 

I missed you post sorry. Yes I have read that.

 

It made me change how slightly how I was going to be this in my main application, which works nicely as I have put the C# part of the notification into the C# UI Application context and that closes down correctly when the C# UI closes.

 

For me side tester application, I realized a unclean closure, did not really matter, it would close and exist itself about 30 seconds after the error message popup up and as it sole function was to aid in testing the TestStand sequences without the UI running, this was fine. 

Danny Thomson AshVire Ltd
0 Kudos
Message 3 of 3
(858 Views)