I want to close all windows and exit Client.exe by clicking the [X] icon in the upper right corner of the main window and floating window.
In that way, you are running the MS-DOS command “taskKill” command in the plugin DLL 's Close (). (* 1)
From the outside this way it seems Client.exe is finished properly, but is there a problem?
If there is a problem, what is missing?
(* 1) “taskkill / IM Client.exe”
The recommended way to shut down the Smart Client from plugin code is to use ApplicationControlCommand..
EnvironmentManager.Instance.SendMessage(
new VideoOS.Platform.Messaging.Message(MessageId.SmartClient.ApplicationControlCommand, VideoOS.Platform.Messaging.ApplicationControlCommandData.Close),
null,
null);
If you execute the following source code (A) in the plug-in Close () and execute it, an error dialog (B) is displayed. Close () is not described except (A). Is there any source code shortage?
A:
EnvironmentManager.Instance.SendMessage(
new VideoOS.Platform.Messaging.Message(MessageId.SmartClient.ApplicationControlCommnad,
VideoOS.Platform.Messaging.ApplicationCommandData.Close),
null, null )
B:
“We encountered a problem with XProtect Smart Client and will end it, sorry for the inconvenience.”
What version of the Smart Client are you testing with?
Please give me the exception text from the error dialog.
From where in your plug-in do you do the send message? Background, viemitem, ..?
Where is the Close() method? Is this a view item or sidepanel or something else?
>What version of the Smart Client are you testing with?
Looking at the properties of Client.exe, the product version is 11.3.5240.1.
>Please give me the exception text from the error dialog.
Exception Type : System.NullReferenceException
Exception Message : Object reference not set to an instance of an object.
Exception Source : WriteViewItemStates
Place VideoOS.RemoteClient.Application.Controllers.MultiWindowController.WriteViewItemStates(XmlText Writer xmlTextWriter, DetachedWindowInfoBase detachedWindowInfoBase)
Place VideoOS.RemoteClient.Application.Controllers.MultiWindowController.GetMultiWindowStateInfo()
Place VideoOS.RemoteClient.Application.Application.GetUserLoggedOnSessionState()
Place VideoOS.RemoteClient.Application.Application.SaveUserLoggedOnLocalSettings()
Place VideoOS.RemoteClient.Application.Application.Logout(Boolean& cancelled)
Place VideoOS.RemoteClient.Application.Application.Closing(CancelEventArgs e)
Place System.Windows.Window.OnClosing(CancelEventArgs e)
Place System.Windows.window.WmClose()
< continue…>
>From where in your plug-in do you do the send message? Background, viemitem, ..?
Sending message is being sent from Close () of plug-in SCViewAndWindow.
>Where is the Close() method? Is this a view item or sidepanel or something else?
This is the Close () method of the plugin SCViewAndWindow. It is in the view.
When using this in a Close() use
EnvironmentManager.Instance.PostMessage(new VideoOS.Platform.Messaging.Message(MessageId.SmartClient.ApplicationControlCommand, VideoOS.Platform.Messaging.ApplicationControlCommandData.Close), null, null);
PostMessage will gently wait as it never returns a result, compared to SendMessage that might return a result and therefore executes.
What happens is that in the Close() method you have a lot of stuff closing down, when then the SendMessage cause this closing to be interrupted and the whole Smart Client is closing. In hindsight I should not have recommended SendMessage but PostMessage, the scenario in which you are using this is a scenario where it makes a difference.
A general recommendation is to use PostMessage when you know you will not have a result returned.