无法从另一个线程调用UccContext.AddNamedProperty [英] Unable to call UccContext.AddNamedProperty from another thread

查看:52
本文介绍了无法从另一个线程调用UccContext.AddNamedProperty的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


当我尝试从另一个线程访问UccContext类的AddNamedProperty时,我得到"尝试读取/写入受保护的内存"。错误。以下代码段显示了将参与者添加到"pSession"的示例。我们之前创建的。
我的需求不仅限于在代码段中添加参与者,还包括发布在线状态,执行即时消息和与语音相关的操作。


代码段:             

 //使用传递的SIP uri $创建会话参与者b $ b UccUriManager uriManager = new UccUriManager(); 
UccUri u = uriManager.ParseUri(con​​tactURI);

// UccContext ctx = new UccContext();
//ctx.AddNamedProperty("User" ;, u.User);
IUccSessionParticipant p = pSession.CreateParticipant(uriManager.ParseUri(con​​tactURI),null);

UccOperationContext operationContext = new UccOperationContext();
UccContext pContext = new UccContext();
// pContext.AddNamedProperty(" OpCaller"," session.AddParticipant");
operationContext.Initialize(1,null);

pSession.AddParticipant(p,operationContext);

上面的代码在主线程中使用时效果很好,但是当从另一个线程使用时它会出错。


<请提供解决方案。


提前致谢。


Annie




解决方案

你好吗?使用此代码

  UpdateVariables   字符串 消息   
{
if InvokeRequred
{ < span class ="pln">
this EndInvoke BeginInvoke new MethodInvoker 委托 () { UpdateVariables 消息 ); } )));
}
< span class ="kwd"> else
{
m_uc
= new UccContextClass ();
iRef
= m_uc 计数
}
}


Hi Everyone,

When I try to access AddNamedProperty of UccContext class from another thread, I am getting "Attempted to read/write protected memory" error. Following code snippet shows the example of adding a participant to the "pSession" which we have created before. My need is not just limited to adding participants as provided in the code snippet but also to publish presence, perform IM and Voice related operations.

Code Snippet:            

    //create a session participant using the passed SIP uri
                UccUriManager uriManager = new UccUriManager();
                UccUri u = uriManager.ParseUri(contactURI);

                //UccContext ctx = new UccContext();
                //ctx.AddNamedProperty("User", u.User);
                IUccSessionParticipant p = pSession.CreateParticipant(uriManager.ParseUri(contactURI), null);

                UccOperationContext operationContext = new UccOperationContext();
                UccContext pContext = new UccContext();
               // pContext.AddNamedProperty("OpCaller", "session.AddParticipant");
                operationContext.Initialize(1, null);

                pSession.AddParticipant(p, operationContext);

The above code works perfectly fine when used in the main thread but it gives the error when used from another thread.

Kindly provide me with the solution to this problem.

Thanks in advance.

Annie

解决方案

Hi could you try to use this code

UpdateVariables(string message)
{
 if (this.InvokeRequred)
 {
  this.EndInvoke(this.BeginInvoke(new MethodInvoker(delegate() { UpdateVariables(message); } )));
 }
 else
 {
m_uc = new UccContextClass();
iRef = m_uc.Count;
 }
}


这篇关于无法从另一个线程调用UccContext.AddNamedProperty的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆