• V20: 3CX Re-engineered. Get V20 for increased security, better call management, a new admin console and Windows softphone. Learn More.

API 3CX MyPhonePlugins.CRMPluginDispose

Status
Not open for further replies.

gdesnoues

Customer
Joined
Dec 16, 2015
Messages
28
Reaction score
2
Hello,

I am coding an interface DLL with 3CX.
I followed the information on this page.
I can detect status changes (call, status)
But you can not figure out how to do an action when closing the 3CX app
Code:
Code:
[MyPhonePlugins.CRMPluginDispose]
public static void Dispose () => DoSomething ();
my function is never called.
An idea of how?

thanks in advance
 
You can use a C# finalizer:
~MyPlugin()
{
// some finalization code here...
}
 
I have try it but the code in ~MyPlugin() are not running when I close 3CX

My loading part :
Code:
        // 3CX loading
        [MyPhonePlugins.CRMPluginInitializer]
        public static void Loader(MyPhonePlugins.IMyPhoneCallHandler callHandler) => instance = new MyPlugin(callHandler);

        // Finalizer
        ~MyPlugin(  )
        {
            System.Diagnostics.Process.Start("https://localhost/byby");
        }

        // Constructor
        private MyPlugin(MyPhonePlugins.IMyPhoneCallHandler callHandler)
        {
            this.callHandler = callHandler;
            callHandler.OnCallStatusChanged += new MyPhonePlugins.CallInfoHandler(callHandler_OnCallStatusChanged);                 //call status
            callHandler.OnMyPhoneStatusChanged += new MyPhonePlugins.MyPhoneStatusHandler(callHandler_OnMyPhoneStatusChanged);      //phone status
            callHandler.CurrentProfileChanged += callHandler_CurrentProfileChanged;                                                 //user status                                 
            MyPlugin = new MyPlugin();
        }
 
Last edited:
Have you checked the example provided with the disposer?
Code:
namespace TCX.CallTriggerCmd
{
    [MyPhonePlugins.CRMPluginLoader]
    public class CallTriggerCmdPluginLoader
    {
        private static object lockObj = new object();
        private static CallTriggerCmdPlugin instance = null;

        [MyPhonePlugins.CRMPluginInitializer]
        public static void Loader(MyPhonePlugins.IMyPhoneCallHandler callHandler)
        {
            lock (lockObj)
            {
                instance = new CallTriggerCmdPlugin(callHandler);
                instance.StartServiceAsync();
            }
        }

        [MyPhonePlugins.CRMPluginDispose]
        public static void Unloader()
        {
            lock(lockObj)
            {
                if ( instance != null )
                {
                    instance.Dispose();
                    instance = null;
                }
            }
        }

    }
}

That should work...

Please also check that your license is PRO, as that is required for this to work...
 
Yes! thank you so much, it's works well now.
I put the code to help others :)
Code:
// Init Var
        private static object lockObj = new object();
// 3CX loading
        [MyPhonePlugins.CRMPluginInitializer]
        public static void Loader(MyPhonePlugins.IMyPhoneCallHandler callHandler)
        {
            lock(lockObj)
            {
                instance = new MyPlugin(callHandler);
            }
        }

        // 3CX Finalizer
        [MyPhonePlugins.CRMPluginDispose]
        public static void Unloader()
        {
            lock(lockObj)
            {
                // something to do .....
                instance = null;
            }
        }
 
Status
Not open for further replies.

Getting Started - Admin

Latest Posts

Forum statistics

Threads
141,622
Messages
748,858
Members
144,736
Latest member
MaxFrank
Get 3CX - Absolutely Free!

Link up your team and customers Phone System Live Chat Video Conferencing

Hosted or Self-managed. Up to 10 users free forever. No credit card. Try risk free.

3CX
A 3CX Account with that email already exists. You will be redirected to the Customer Portal to sign in or reset your password if you've forgotten it.