The following code snippet demonstrates an example of this process.
static class Program
{
[STAThread]
static void Main()
{
using (Dispatcher disp = Dispatcher.AttachUIDispatcher())
{
Application.EnableVisualStyles();
MyApp myApp = new MyApp();
string appSecretKey = "Your App Key";
environment,
appSecretKey);
TTSetupSDK.CreateTTSetupSDK(disp, apiConfig, apiInitializeHandler);
Application.Run(myApp);
}
}
}
public partial class MyApp : Form
{
private TTSetupSDK m_sdk = null;
private bool m_isShutdown = false, m_shutdownInProcess = false;
public MyApp()
{
InitializeComponent();
}
public void TTSetupSdkInitHandler(TTSetupSDK sdk, ApiCreationException ex)
{
if (ex == null)
{
Console.WriteLine("TT SETUP SDK Initialization Complete");
m_sdk = sdk;
m_sdk.TTSetupSDKStatusUpdate += M_sdk_TTSetupSDKStatusUpdate;
m_sdk.Start();
}
else if (ex.IsRecoverable)
{
}
else
{
MessageBox.Show("API Initialization Failed: " + ex.Message);
}
}
public void M_sdk_TTSetupSDKStatusUpdate(object sender, TTSetupStatusUpdateEventArgs e)
{
Console.WriteLine("TTSetupSDKStatusUpdate: {0}", e);
if (e.IsReady == false)
{
return;
}
}
public void shutdownTTSetupSDK()
{
if (!m_shutdownInProcess)
{
TTSetupSDK.ShutdownCompleted += new EventHandler(TTSetupSDK_ShutdownCompleted);
TTSetupSDK.Shutdown();
m_shutdownInProcess = true;
}
}
public void TTSetupSDK_ShutdownCompleted(object sender, EventArgs e)
{
m_isShutdown = true;
Close();
}
protected override void OnFormClosing(FormClosingEventArgs e)
{
if (!m_isShutdown)
{
e.Cancel = true;
shutdownTTSetupSDK();
}
else
{
base.OnFormClosing(e);
}
}
}