Exemplo n.º 1
0
        // 根据当前需要保存的记录路径,自动准备 Channel
        // 尽量利用以前的 Channel,如果 Url 没有变化的话
        public static RmsChannel GetChannel(
            RmsChannelCollection Channels,
            Stop stop,
            string strUrl,
            RmsChannel cur_channel)
        {
            RmsChannel old_channel = cur_channel;

            // 准备 Channel
            if (cur_channel.Url != strUrl)
            {
                cur_channel.Close();
                cur_channel = Channels.CreateTempChannel(strUrl);

                if (old_channel != null)
                {
                    stop.OnStop -= (sender1, e1) =>
                    {
                        if (old_channel != null)
                            old_channel.Abort();
                    };
                }
                stop.OnStop += (sender1, e1) =>
                {
                    if (cur_channel != null)
                        cur_channel.Abort();
                };
            }

            return cur_channel;
        }