# an exception occurred when using delegate

**URL:** <https://forums.unrealengine.com/t/an-exception-occurred-when-using-delegate/37694>\
**Category:** C++\
**Tags:** unreal-engine\
**Created:** [August 6, 2015, 1:22am UTC](https://forums.unrealengine.com/t/an-exception-occurred-when-using-delegate/37694 "2015-08-06T01:22:54Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_71046e02](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_71046e02](https://forums.unrealengine.com/u/anonymous_user_71046e02)\
**Post date:** [August 6, 2015, 1:22am UTC](https://forums.unrealengine.com/t/an-exception-occurred-when-using-delegate/37694/1 "2015-08-06T01:22:54Z")

</div>

In MyActor.h file,I defined a delegate as following :

DECLARE\_DYNAMIC\_MULTICAST\_DELEGATE\_OneParam(FNewDataComes, FString, locationData);  
UPROPERTY(BlueprintAssignable, Category = “NotifyData”)  
FNewDataComes OnDataUpdated;

In MyActor.cpp file,i create a thread to receive data from another application.When new data comes,i use the delegate to notify the concerning blueprint.The thread i create is as following:

DWORD32 WINAPI MyStartReceiveData(LPVOID myparam)  
{  
//持续监听接收数据  
char pszRecv[4096];  
AMyActor\* pDlg = (AMyActor\*)myparam;  
if (pDlg == NULL)  
return 0;  
while(true)  
{  
if (ConnectSocket!=NULL)  
{  
int nrev = recv(ConnectSocket, pszRecv, 4096, 0);  
if (nrev\>0)  
{  
pszRecv[nrev] = ‘\0’;  
pDlg-\>OnDataUpdated.Broadcast(pszRecv);  
}  
}  
}  
return 0;  
}

When i click the play button,the blueprint does receive the new data.However,when i end playing the game,an exception occurred as following:  
SOutlinerTreeView.cpp(i never used it)

 ![530FQM}7I`W(6~13DT48C7G.png](https://d3kjluh73b9h9o.cloudfront.net/original/3X/4/8/48d87c9478ad3b72343e80c0ec826198799b41bc.png)
