public void Initialize() { if (IsInitialized) { throw new InvalidOperationException("BluesoleilService is already initialized."); } createdThread = Thread.CurrentThread; if (!NativeMethods.BT_InitializeLibrary()) { throw new BluesoleilException("The library could not be initialized."); } CONNECTION_STATUS_DELEGATE = new NativeMethods.PCALLBACK_CONNECTION_STATUS(static_CONNECTION_STATUS_CALLBACK); BLUETOOTH_STATUS_DELEGATE = new NativeMethods.PCALLBACK_BLUETOOTH_STATUS(static_BLUETOOTH_STATUS_CALLBACK); NativeMethods.BT_RegisterCallback(NativeMethods.EVENT.EVENT_CONNECTION_STATUS, CONNECTION_STATUS_DELEGATE); NativeMethods.BT_RegisterCallback(NativeMethods.EVENT.EVENT_BLUETOOTH_STATUS, BLUETOOTH_STATUS_DELEGATE); _IsInitialized = true; }
public void Initialize() { if (IsInitialized) throw new InvalidOperationException("BluesoleilService is already initialized."); createdThread = Thread.CurrentThread; if (!NativeMethods.BT_InitializeLibrary()) throw new BluesoleilException("The library could not be initialized."); CONNECTION_STATUS_DELEGATE = new NativeMethods.PCALLBACK_CONNECTION_STATUS(static_CONNECTION_STATUS_CALLBACK); BLUETOOTH_STATUS_DELEGATE = new NativeMethods.PCALLBACK_BLUETOOTH_STATUS(static_BLUETOOTH_STATUS_CALLBACK); NativeMethods.BT_RegisterCallback(NativeMethods.EVENT.EVENT_CONNECTION_STATUS, CONNECTION_STATUS_DELEGATE); NativeMethods.BT_RegisterCallback(NativeMethods.EVENT.EVENT_BLUETOOTH_STATUS, BLUETOOTH_STATUS_DELEGATE); _IsInitialized = true; }