# Call back to Clarion from a .Net control

**URL:** <https://clarionhub.com/t/call-back-to-clarion-from-a-net-control/1808>\
**Category:** Interop\
**Created:** [April 27, 2018, 12:02am UTC](https://clarionhub.com/t/call-back-to-clarion-from-a-net-control/1808 "2018-04-27T00:02:03Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![brahn](https://clarionhub.com/user_avatar/clarionhub.com/brahn/32/756_2.png) [@brahn](https://clarionhub.com/u/brahn)\
**Post date:** [April 27, 2018, 12:02am UTC](https://clarionhub.com/t/call-back-to-clarion-from-a-net-control/1808/1 "2018-04-27T00:02:03Z")

</div>

This is a continuation of a longer conversation on Skype, with reference to a ClarionLive webinar and example code by @hdsoftware

> I managed to get your demo code (SQLQuery) to call back to clarion it was a matter of using the runtime AttachThreadToClarion call from the control itself, then just pass in the procedure/s you want to call back.

So in the global cs file I have

```auto
public delegate void CallbackProc();
static CallbackProc callbackProc;

```

Then in the initiate procedure in the global cs file changed to and added a calling procedure

```auto
 [DllExport("SQLQueryTool_Initiate", CallingConvention = CallingConvention.StdCall, ExportName = "SQLQueryTool_Initiate")]
 public static void SQLQueryTool_Initiate(int SQLQueryToolWrapperHandle, CallbackProc cb)
 {
     callbackProc = cb;
     Controls.SQLQueryTool.CreateControl(SQLQueryToolWrapperHandle, new Controls.SQLQueryTool());
 }
[DllImport("ClaRun.dll", CallingConvention = CallingConvention.StdCall, EntryPoint = "AttachThreadToClarion")]
        public static extern void AttachThreadToClarion(int allocateThread);
public static void callCallback()
{
     AttachThreadToClarion(1);
     callbackProc();
 }

```

Then from the form just call the global callCallback method
