标题:请问回调函数怎么使用啊
只看楼主
luohaiping3
Rank: 2
等 级:论坛游民
帖 子:35
专家分:20
注 册:2014-11-6
结帖率:66.67%
 问题点数:0 回复次数:2 
请问回调函数怎么使用啊
Upgrade(long lLoginID, char *sFileName, int nType = 0, fUpgradeCallBack cbUpgrade = NULL, long dwUser = 0);

fUpgradeCallBack (long lLoginID, long lUpgradechannel, int nTotalSize, int nSendSize, long dwUser);

怎样才能把回调函数中的nTotalSize,nSendSize的值获取到文本框中去
搜索更多相关主题的帖子: 文本框 
2016-01-25 10:25
luohaiping3
Rank: 2
等 级:论坛游民
帖 子:35
专家分:20
注 册:2014-11-6
得分:0 
这是我写的一点代码,还请大家帮我看看
private SDK.fUpgradeCallBack fUpgradeCallBack;
private void button2_Click(object sender, EventArgs e)
{
      t = new Thread(new ThreadStart(Threadp)); //实例化线程
      t.Start();//启动线程      
     lUpgradeID = SDK.Upgrade(Form1.lLoginID, textBox1.Text, 0, fUpgradeCallBack, this.Handle);
}
public void Threadp()
        {
            //C#方必须申明一个变量,用来指向C++的回调指针函数,避免被C#回收掉。
            fUpgradeCallBack = new XMSDK.fUpgradeCallBack(FUpgradeCallBackFun);
            this.BeginInvoke(fUpgradeCallBack, "123"); // 异步调用委托,调用后立即返回并立即执行下面的语句
            //...
        }
    结果报错  Application.Run(new Form1());//参数计数不匹配
        private void FUpgradeCallBackFun(int lLoginID, int lUpgradechannel, int nTotalSize, int nSendSize, int dwUser)//升级回调
        {
            //处理dll传过来的数据
            progressBar1.Minimum = 0;
            progressBar1.Maximum = nTotalSize;
            progressBar1.Value = nSendSize;
            Thread.Sleep(200);
        }

[此贴子已经被作者于2016-1-25 17:23编辑过]


新手上路,请大家多多指教
2016-01-25 11:04
luohaiping3
Rank: 2
等 级:论坛游民
帖 子:35
专家分:20
注 册:2014-11-6
得分:0 
已经好了...

新手上路,请大家多多指教
2016-01-26 16:21



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-461337-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.019483 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved