当前位置: 首页 > news >正文

广州企业建设网站福州百度推广排名

广州企业建设网站,福州百度推广排名,js网页设计案例,沈阳网站建设制作真的非常感谢CnBlogs.com,因为有很多教程里写的知识点并不全面,而且也没附带例子.通过这里我学习到了很多很多.希望网站能越办越好哦.下面是我学习分布式开发时写的一个小demo,当然功能有限,技术也很低.希望大师们能拍拍砖,不吝赐教.呵呵软件运行的一个截图下面说说流程吧,1:利…真的非常感谢CnBlogs.com,因为有很多教程里写的知识点并不全面,而且也没附带例子.通过这里我学习到了很多很多.希望网站能越办越好哦.下面是我学习分布式开发时写的一个小demo,当然功能有限,技术也很低.希望大师们能拍拍砖,不吝赐教.呵呵软件运行的一个截图下面说说流程吧,1:利用public static object CreateInstance(Type type, object[] args, object[] activationAttributes);方法创建一个类(并激活自定义的构造函数)2:利用MSMQ异步接收事件参数来触发remoting的事件大约就是这样的里程,不过看上去蛮简单的,可里面用到很多MSMQ和remoting事件的知识点哦..下面是一段在remoting里面调用的dll原代码Codeusing System;using System.Collections.Generic;using System.Text;using System.Messaging; //此空间必须引用Mssaging空间才能访问哦namespace MyRemotingAndMsmq{    /*     *关于Remoting和MSMQ系列的文章博客园里有很多     *而且介绍的又很全面在此我也就不具体的讲解了。     *在此篇博客里我主要是针对Remoting和MSMQ结合的一些问题做个demo.     *并在重点处做个标记本文并不全文注释如有任何疑问请发表看法     *欢迎大家互相学习切磋。     *此程序具体流程很简单如下解释     *一利用一个Class定义个串行化类并传给RemotingRemoting接收MSMQ     * 里的参数并在客户端用Remoting事件触发来接收内容。其实真实过程中     * 并不需要这么多的流程只是本文是用来阐述这两种方法结合使用的例子所以     * 很多此一举呵呵。。。。    */    public class MyContext : MarshalByRefObject  //此类用来虚拟实例化事件参数类的类    {        private string name  null;        private string address  null;        private string message  null;        public MyContext(string name, string address, string message) //此构造函数将用客户端激活模式来激活        {            this.name  name;            this.address  address;            this.message  message;        }        public string Name        {            get { return name; }            set { name  value; }        }        public string Address        {            get { return address; }            set { address  value; }        }        public string Message        {            get { return message; }            set { message  value; }        }    }    [Serializable]  //此类是用来    public class MyEvent:EventArgs    {        private string name  null;        private string address  null;        private string message  null;        public MyEvent(string name, string address, string message) //此构造函数将用客户端激活模式来激活        {            this.name  name;            this.address  address;            this.message  message;        }        public string Name        {            get { return name; }            set { name  value; }        }        public string Address        {            get { return address; }            set { address  value; }        }        public string Message        {            get { return message; }            set { message  value; }        }    }    public class MyMsmq : MarshalByRefObject  //因为需要传动MyMsmq类所以需要编组    {        public string context 触发事件;  //因为此字段需要在类外部访问所以需要定义public级别        string name  .\private$\my;        MessageQueue mm  null;        public MyContext mycontext  null;        public void Shu()        {            if (MessageQueue.Exists(name))            {                mm  new MessageQueue(name);            }            else            {                mm  MessageQueue.Create(name);            }            context  mycontext.Name  ,  mycontext.Address  ,  mycontext.Message;            System.Messaging.Message m  new System.Messaging.Message();            m.Label  异步消息发送;            m.Bodycontext;            mm.Send(m);            mm.ReceiveCompleted  new ReceiveCompletedEventHandler(mm_ReceiveCompleted); //定义异步接收的事件            mm.BeginReceive();        }        void mm_ReceiveCompleted(object sender, ReceiveCompletedEventArgs e)        {            MessageQueue mq  (MessageQueue)sender;            System.Messaging.Message m  mq.EndReceive(e.AsyncResult);            m.Formatter  new XmlMessageFormatter(new Type[] { typeof(string) });            context  m.Body.ToString();//改变context            mq.BeginReceive();//接收下一次事件         }    }    public class MyRemoting : MarshalByRefObject    {        public string context;        string[] contexts;        public delegate void MyDeledate(object sender, MyEvent e);        public event MyDeledate MyHandle;        MyEvent e  null;        public MyMsmq mm  null;        public void Shu()        {            if ((mm.context ! 触发事件))  //这里代表MSMQ异步接收事件成功            {                contexts  mm.context.Split(new char[]{ ,});                if (contexts.Length  2  contexts.Length  0)                {                    e  new MyEvent(contexts[0].ToString(), contexts[1].ToString(), 自定义参数);                    MyHandle(this, e);                }                if (contexts.Length  1)                {                    e  new MyEvent(contexts[0].ToString(), contexts[1].ToString(), contexts[2].ToString());                    MyHandle(this, e);                }                            }        }    }}服务器端需要创建3个远程对象,typeof(MyContext),typeof(MyMsmq),typeof(MyRemoting).代码如下Code    private void Form1_Load(object sender, EventArgs e)        {            RemotingConfiguration.ApplicationName  remotingandmsmq; //客户激活模式需要的URI需要在此定义            BinaryServerFormatterSinkProvider bk  new BinaryServerFormatterSinkProvider();            BinaryClientFormatterSinkProvider ck  new BinaryClientFormatterSinkProvider();            bk.TypeFilterLevel  TypeFilterLevel.Full;            Dictionarystring, string wo  new Dictionarystring, string();            wo[port]  8086;            TcpChannel tcp  new TcpChannel(wo, ck, bk);//因为TcpServerChannl不支持安全性所以用TcpChannel            ChannelServices.RegisterChannel(tcp);            RemotingConfiguration.RegisterActivatedServiceType(typeof(MyContext));            RemotingConfiguration.RegisterActivatedServiceType(typeof(MyMsmq));            RemotingConfiguration.RegisterActivatedServiceType(typeof(MyRemoting));        }原代码下载这只是一个空的winform服务器,目的是在等待客户端调用.客户端调用如下Code   private void button1_Click(object sender, EventArgs e)        {            //RemotingConfiguration.RegisterActivatedClientType(typeof(MyContext), tcp://localhost:8086/remotingandmsmq);            object[] obj { new UrlAttribute(tcp://localhost:8086/remotingandmsmq) };            object[] objs  new object[3];            objs[0]  小徐;            objs[1]  扬州;            objs[2]  能不能触发了;            MyContext mm  (MyContext)Activator.CreateInstance(typeof(MyContext), objs, obj);            //以上利用public static object CreateInstance(Type type, object[] args, object[] activationAttributes);            //来完成类MyContext的构造函数            RemotingConfiguration.RegisterActivatedClientType(typeof(MyMsmq), tcp://localhost:8086/remotingandmsmq);            MyMsmq my  new MyMsmq();            my.mycontext  mm;            my.Shu();            RemotingConfiguration.RegisterActivatedClientType(typeof(MyRemoting), tcp://localhost:8086/remotingandmsmq);            MyRemoting mym  new MyRemoting();            mym.mm  my;            //MessageBox.Show(mym.mm.context.ToString());            ClassLibrary1.Class1 c  new ClassLibrary1.Class1();            mym.MyHandle  new MyRemoting.MyDeledate(c.StatusHandler);            mym.Shu();        }        void mym_MyHandle(object sender, MyEvent e)        {            throw new Exception(The method or operation is not implemented.);        }        private void Form1_Load(object sender, EventArgs e)        {            BinaryServerFormatterSinkProvider serverProvider  new BinaryServerFormatterSinkProvider();            BinaryClientFormatterSinkProvider clientProvider  new BinaryClientFormatterSinkProvider();            serverProvider.TypeFilterLevel  TypeFilterLevel.Full;            Dictionarystring, string wo  new Dictionarystring, string();            wo[port]  0;            TcpChannel channel  new TcpChannel(wo, clientProvider, serverProvider);            ChannelServices.RegisterChannel(channel);        }网站里关于这两个话题的博客很多,在这里我就不多加解释了,网友们自行查阅资料.重点地方我都做下注释了......转载于:https://www.cnblogs.com/xuting/archive/2009/07/27/1532069.html
http://www.pierceye.com/news/247261/

相关文章:

  • 做网站时已做好了ps怎么倒入深圳燃气公司地址
  • 做类似淘宝的网站要多少钱亚马逊网站建设进度计划书
  • 够完美网站建设怎么把视频弄成超链接
  • 苏州网站建设哪家更好四川省建设工程信息网官网二建注册
  • 潍坊网站关键词推广湖南餐饮网站建设
  • 珠海网站建设优化推广win2008 iis7发布网站
  • 平安网站建设发挥了积极的作用wordpress 的数据库路径
  • 福州网站建设优化安阳县二中录取分数线2022
  • 如何建手机网站网站能否做二维码
  • 南京网站建设 雷仁网上海网站制作网络推广方法
  • 营销型网站怎么做安阳县有多少个乡镇
  • 网站评论 设计天气网站建设
  • 潍坊市住房和城乡建设局网站哈尔滨最新发布公告
  • 白云网站 建设信科网络制作网站软件网站
  • 房产网站的建设想发布oa网站 需要备案吗
  • 帮别人做钓鱼网站吗海口网站建设过程
  • 广州php网站建设做网站的公司推荐
  • 百度一下建设银行网站首页网上购物都有哪些网站
  • 装饰公司营销型网站建设idc服务器租赁
  • 广告投放跟网站建设一样吗视频网站能备案吗
  • 哪些网站可以找到兼职做报表的学校网站建设价格明细表
  • 域名购买哪个网站好wordpress 转载插件
  • 网站百度提示风险网站开发 安全
  • 厦门网站建设建网站如何做一个网页项目
  • 锦州市网站建设腾讯企点怎么群发
  • 移动端网站开发哪家好总结格式模板
  • 东山县建设银行网站民宿网站开发的开题报告
  • 北京企业网站seo平台社交网站模板下载
  • 旅游做攻略用什么网站wordpress破解版
  • 杭州做购物网站第一次跑业务怎么找客户