• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# IDisposable类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中IDisposable的典型用法代码示例。如果您正苦于以下问题:C# IDisposable类的具体用法?C# IDisposable怎么用?C# IDisposable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IDisposable类属于命名空间,在下文中一共展示了IDisposable类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Add

 public void Add(IDisposable component)
 {
     if (component != null)
     {
         this.components.Add(component);
     }
 }
开发者ID:Motaz-Al-Zoubi,项目名称:xaml-sdk,代码行数:7,代码来源:CompositeDisposableObject.cs


示例2: ItemAutoSubscription

 /// <summary>
 ///   Initializes a new instance of the <see cref = "ItemAutoSubscription" /> class.
 /// </summary>
 /// <param name = "item">
 ///   The subscribed item.
 /// </param>
 /// <param name = "itemPosition">
 ///   The item position.
 /// </param>
 /// <param name = "itemRegion">
 ///   The item Region.
 /// </param>
 /// <param name = "subscription">
 ///   The subscription.
 /// </param>
 public ItemAutoSubscription(Item item, Vector itemPosition, Region itemRegion, IDisposable subscription)
 {
     this.ItemPosition = itemPosition;
     this.item = item;
     this.subscription = subscription;
     this.WorldRegion = itemRegion;
 }
开发者ID:ommziSolution,项目名称:PhotonServer,代码行数:22,代码来源:ItemAutoSubscription.cs


示例3: SetVideoCodecToken

		/// <summary>
		/// sets the codec token to be used for video compression
		/// </summary>
		public void SetVideoCodecToken(IDisposable token)
		{
			if (token is CodecToken)
				currVideoCodecToken = (CodecToken)token;
			else
				throw new ArgumentException("AviWriter only takes its own Codec Tokens!");
		}
开发者ID:ddugovic,项目名称:RASuite,代码行数:10,代码来源:AviWriter.cs


示例4: Create

        /// <summary>
        /// Creates a new group containing two disposable resources that are disposed together.
        /// </summary>
        /// <param name="disposable1">The first disposable resoruce to add to the group.</param>
        /// <param name="disposable2">The second disposable resoruce to add to the group.</param>
        /// <returns>Group of disposable resources that are disposed together.</returns>
        public static ICancelable Create(IDisposable disposable1, IDisposable disposable2)
        {
            if (disposable1 == null) throw new ArgumentNullException("disposable1");
            if (disposable2 == null) throw new ArgumentNullException("disposable2");

            return new Binary(disposable1, disposable2);
        }
开发者ID:ClusterVR,项目名称:teleportation_for_vive,代码行数:13,代码来源:StableCompositeDisposable.cs


示例5: Configure

        private void Configure(AzureServiceBusOwinServiceConfiguration config, Action<IAppBuilder> startup)
        {
            if (startup == null)
            {
                throw new ArgumentNullException("startup");
            }

            var options = new StartOptions();
            if (string.IsNullOrWhiteSpace(options.AppStartup))
            {
                // Populate AppStartup for use in host.AppName
                options.AppStartup = startup.Method.ReflectedType.FullName;
            }

            var testServerFactory = new AzureServiceBusOwinServerFactory(config);
            var services = ServicesFactory.Create();
            var engine = services.GetService<IHostingEngine>();
            var context = new StartContext(options)
            {
                ServerFactory = new ServerFactoryAdapter(testServerFactory),
                Startup = startup
            };
            _started = engine.Start(context);
            _next = testServerFactory.Invoke;
        }
开发者ID:pmhsfelix,项目名称:ndc-london-13-web-api,代码行数:25,代码来源:AzureServiceBusOwinServer.cs


示例6: LightningQueuesChannel

 public LightningQueuesChannel(Uri address, string queueName, Queue queueManager)
 {
     Address = address;
     _queueName = queueName;
     _queueManager = queueManager;
     _disposable = Disposable.Empty;
 }
开发者ID:DarthFubuMVC,项目名称:fubumvc,代码行数:7,代码来源:LightningQueuesChannel.cs


示例7: Open

        public static void Open(params string[] hostUrls)
        {
            try
            {
                if (_CloseOWin == null)
                {
                    // Start OWIN host
                    StartOptions so = new StartOptions();
                    foreach (string s in hostUrls)
                    {
                        so.Urls.Add(s);
                    }
                    _CloseOWin = WebApp.Start<SNStartup>(so);
                }
            }
            catch (Exception ex)
            {
                if (ex.InnerException is System.Net.HttpListenerException)
                {
                    throw new Exception("监听IP有错误");
                }

                if (_CloseOWin != null)
                {
                    _CloseOWin.Dispose();//必须
                    _CloseOWin = null;//必须
                }

                throw;
            }
        }
开发者ID:fengxingshi,项目名称:CZJC,代码行数:31,代码来源:SNOwin.cs


示例8: NodeViewModel

        public NodeViewModel(Node node, Vector location, IControlTypesResolver controlTypesResolver)
        {
            Node = node;
            Title = node.Title;
            Location = new CanvasPoint(location);
            ControlTypesResolver = controlTypesResolver;

            foreach (var pin in node.InputPins)
            {
                AddInputPin(pin);
            }

            foreach (var pin in node.OutputPins)
            {
                AddOutputPin(pin);
            }

            node.Processed += OnNodeProcessed;
            node.PinsChanged += OnNodePinsChanged;

            _disposable = Disposable.Create(() =>
            {
                node.PinsChanged -= OnNodePinsChanged;
                node.Processed -= OnNodeProcessed;
            });
        }
开发者ID:misupov,项目名称:Turbina,代码行数:26,代码来源:NodeViewModel.cs


示例9: MDRefactoringScript

		public MDRefactoringScript (MDRefactoringContext context, CSharpFormattingOptions formattingOptions) : base(context.TextEditor.Document, formattingOptions, context.TextEditor.CreateNRefactoryTextEditorOptions ())
		{
			this.context = context;
			undoGroup  = this.context.TextEditor.OpenUndoGroup ();
			this.startVersion = this.context.TextEditor.Version;

		}
开发者ID:sturmrutsturm,项目名称:monodevelop,代码行数:7,代码来源:MDRefactoringScript.cs


示例10: Dispose

        public void Dispose()
        {
            if(_storeSubscription == null)
                return;

            _storeSubscription.Dispose();
            _storeSubscription = null;

            _pluginChannel.Do(x => x.Value.Dispose());
            _pluginChannel.Clear();
            _pluginChannel = null;

            _pluginServer.Do(x => x.Value.Dispose());
            _pluginServer.Clear();
            _pluginServer = null;

            _pluginGlobal.Do(x => x.Value.Dispose());
            _pluginGlobal.Clear();
            _pluginGlobal = null;

            _channel.Do(x => x.Value.Dispose());
            _channel.Clear();
            _channel = null;

            _server.Do(x => x.Value.Dispose());
            _server.Clear();
            _server = null;

            _global.Dispose();
            _global = null;
        }
开发者ID:Gohla,项目名称:Veda,代码行数:31,代码来源:StorageManager.cs


示例11: VirtualListVewModel

        public VirtualListVewModel(SynchronizationContext bindingContext, DataService service)
        {
            _virtualRequest = new BehaviorSubject<VirtualRequest>(new VirtualRequest(0,10));

            Items = new BindingList<Poco>();

            var sharedDataSource = service
                .DataStream
                .Do(x => Trace.WriteLine($"Service -> {x}"))
                .ToObservableChangeSet()
                .Publish();

            var binding = sharedDataSource
                          .Virtualise(_virtualRequest)
                          .ObserveOn(bindingContext)
                          .Bind(Items)
                          .Subscribe();
            
            //the problem was because Virtualise should fire a noticiation if count changes, but it does not [BUG]
            //Therefore take the total count from the underlying data NB: Count is DD.Count() not Observable.Count()
            Count = sharedDataSource.Count().DistinctUntilChanged();

            Count.Subscribe(x => Trace.WriteLine($"Count = {x}"));

            var connection = sharedDataSource.Connect();
            _disposables = new CompositeDisposable(binding, connection);
        }
开发者ID:RolandPheasant,项目名称:Test-Dynamic-Data,代码行数:27,代码来源:VirtualListVewModel.cs


示例12: Connect

 public void Connect(IEventStream stream)
 {
     subscription = stream.Of<IEventPattern<IDevice, ISensed>>().Subscribe(sensed =>
     {
         var type = topicRegistry.Find(sensed.EventArgs.Topic);
         switch (type)
         {
             case TopicType.Boolean:
                 stream.Push(sensed.Sender, Impulse.Create(sensed.EventArgs.Topic, Payload.ToBoolean(sensed.EventArgs.Payload), clock.Now));
                 break;
             case TopicType.Number:
                 stream.Push(sensed.Sender, Impulse.Create(sensed.EventArgs.Topic, Payload.ToNumber(sensed.EventArgs.Payload), clock.Now));
                 break;
             case TopicType.String:
                 stream.Push(sensed.Sender, Impulse.Create(sensed.EventArgs.Topic, Payload.ToString(sensed.EventArgs.Payload), clock.Now));
                 break;
             case TopicType.Void:
                 stream.Push(sensed.Sender, Impulse.Create(sensed.EventArgs.Topic, Unit.Default, clock.Now));
                 break;
             case TopicType.Unknown:
             default:
                 // TODO: throw? Report?
                 break;
         }
     });
 }
开发者ID:kzu,项目名称:Sensorium,代码行数:26,代码来源:SensedToImpulse.cs


示例13: BeginTransaction

		public bool BeginTransaction ()
		{
			if (inTransaction)
				throw new InvalidOperationException ("Already in a transaction");
			
			transactionLock = LockWrite ();
			try {
				updatingLock = new FileStream (UpdateDatabaseLockFile, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None);
			} catch (IOException) {
				// The database is already being updated. Can't do anything for now.
				return false;
			} finally {
				transactionLock.Dispose ();
			}

			// Delete .new files that could have been left by an aborted database update
			
			transactionLock = LockRead ();
			CleanDirectory (rootDirectory);
			
			inTransaction = true;
			foldersToUpdate = new Hashtable ();
			deletedFiles = new Hashtable ();
			deletedDirs = new Hashtable ();
			return true;
		}
开发者ID:guadalinex-archive,项目名称:guadalinex-v6,代码行数:26,代码来源:FileDatabase.cs


示例14: AggregationViewModel

        public AggregationViewModel()
        {
            var sourceList = new SourceList<AggregationItem>();

            sourceList.AddRange(Enumerable.Range(1, 15).Select(i => new AggregationItem(i)));

            //Load items to display to user and allow them to include items or not
         
            var listLoader = sourceList.Connect()
                .Sort(SortExpressionComparer<AggregationItem>.Ascending(vm => vm.Number))
                .ObserveOnDispatcher()
                .Bind(out _items)
                .Subscribe();

            // share the connection because we are doing multiple aggregations
            var aggregatable = sourceList.Connect()
                .FilterOnProperty(vm => vm.IncludeInTotal, vm => vm.IncludeInTotal)
                .Publish();

            //Do a custom aggregation (ToCollection() produces a readonly collection of underlying data)
            var sumOfOddNumbers = aggregatable.ToCollection()
                .Select(collection => collection.Where(i => i.Number%2 == 1).Select(ai => ai.Number).Sum())
                .Subscribe(sum => SumOfOddNumbers = sum);
            
            _cleanUp = new CompositeDisposable(sourceList, 
                listLoader,
                aggregatable.Count().Subscribe(count => Count = count),
                aggregatable.Sum(ai => ai.Number).Subscribe(sum => Sum = sum),
                aggregatable.Avg(ai => ai.Number).Subscribe(average => Avg = Math.Round(average,2)),
                aggregatable.Minimum(ai => ai.Number).Subscribe(max => Max = max),
                aggregatable.Maximum(ai => ai.Number).Subscribe(min => Min = min),
                aggregatable.StdDev(ai => ai.Number).Subscribe(std => StdDev = Math.Round(std, 2)),
                sumOfOddNumbers,
                aggregatable.Connect());
        }
开发者ID:RolandPheasant,项目名称:DynamicData.Samplz,代码行数:35,代码来源:AggregationViewModel.cs


示例15: SPOEmulationContext

        /// <summary>
        /// Initializes a new instance of the <see cref="SPOEmulationContext"/> class.
        /// </summary>
        /// <param name="isolationLevel">The level.</param>
        /// <param name="connectionInformation">The connection informations for the target web.</param>
        public SPOEmulationContext(IsolationLevel isolationLevel, ConnectionInformation connectionInformation)
        {
            this._isolationLevel = isolationLevel;

            switch (isolationLevel)
            {
                case IsolationLevel.Fake:
                    // create shim context
                    _shimsContext = ShimsContext.Create();

                    // initialize all simulated types
                    _clientContext = InitializeSimulatedAPI(connectionInformation.Url);
                    break;
                case IsolationLevel.Integration:
                    // create shim context
                    _shimsContext = ShimsContext.Create();
                    Connect(connectionInformation);
                    break;
                case IsolationLevel.None:
                    Connect(connectionInformation);
                    break;
                default:
                    throw new InvalidOperationException();
            }
        }
开发者ID:mehrosu,项目名称:SPOEmulators,代码行数:30,代码来源:SPOEmulationContext.cs


示例16: Start

        // global instances that keep controller and windows service alive

        public void Start(QueueMessageManager manager = null)
        {
            if (manager == null)
                manager = new QueueMessageManagerSql();

            LogManager.Current.LogInfo("Start called");

            var config = QueueMessageManagerConfiguration.Current;

            Controller = new QueueController()
            {
                ConnectionString = config.ConnectionString,
                QueueName = config.QueueName,
                WaitInterval = config.WaitInterval,
                ThreadCount = config.ControllerThreads                
            };
            

            LogManager.Current.LogInfo("Controller created.");
            
            // asynchronously start the SignalR hub
            SignalR = WebApplication.Start<SignalRStartup>("http://*:8080/");

            // *** Spin up n Number of threads to process requests
            Controller.StartProcessingAsync();

            LogManager.Current.LogInfo(String.Format("QueueManager Controller Started with {0} threads.",
                                       Controller.ThreadCount));            

            // Set static instances so that these 'services' stick around
            GlobalService.Controller = Controller;
            GlobalService.Service = this;
        }
开发者ID:RickStrahl,项目名称:Westwind.QueueMessageManager,代码行数:35,代码来源:QueueService.cs


示例17: OnStart

        public void OnStart()
        {
            server = WebApp.Start<Startup>("http://+:7774");

            // TODO: Exception handling
            Task.Factory.StartNew(() => provider = new PerformanceDataProvider());
        }
开发者ID:krishnakanthms,项目名称:AngularJSSignalRDashboard,代码行数:7,代码来源:SystemMonitorHost.cs


示例18: ConfigHandler

 public ConfigHandler()
 {
     _binder = SwitchXmlSearchBinding.Bind(XmlCallback,
         switch_xml_section_enum_t.SWITCH_XML_SECTION_DIRECTORY |
         switch_xml_section_enum_t.SWITCH_XML_SECTION_DIALPLAN);
     
 }
开发者ID:prashantchoudhary,项目名称:FreeswitchModified,代码行数:7,代码来源:ConfigHandler.cs


示例19: Start

        public void Start()
        {
            var siteUrl = Settings.Default.SiteUrl;
            var portNumber = Settings.Default.PortNumber;
            var uri = $"http://*:{portNumber}{siteUrl}";

            SmartDBEntities.SetConnection(Settings.Default.DBServer, Settings.Default.DBName,
                Settings.Default.DBUser,
                Encryption.Decrypt(Settings.Default.DBPassword));

            Program.ProcessLog.Write("Database connection string to " + Settings.Default.DBServer +
                                     " has successfully been made.");
            if (SmartDBEntities.IsDBAvailable)
                Program.ProcessLog.Write("Database connection  " + Settings.Default.DBServer +
                                         " has successfully been made.");
            else
                Program.ProcessLog.Write("Database connection  " + Settings.Default.DBServer + " has failed.");
            var options = new StartOptions();
#if DEBUG
            options.Urls.Add($"http://{Environment.MachineName}:15000");
            options.Urls.Add("http://localhost:15000/");
#endif
            options.Urls.Add(uri);
            Host = WebApp.Start<Startup>(options);
        }
开发者ID:MHAWeb,项目名称:MachSecure.SmartLaneOverview.Hub,代码行数:25,代码来源:HostService.cs


示例20: OnInitialize

        protected override void OnInitialize()
        {
            base.OnInitialize();

             var _ecgObservable = EcgSimulator.SimulateEcgAsObservable();
            _disposable = _ecgObservable.Subscribe(s => Debug.WriteLine(s));
        }
开发者ID:eranotz50,项目名称:ReactiveEcgPlotter,代码行数:7,代码来源:EcgViewModel.cs



注:本文中的IDisposable类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IDnaDataReader类代码示例发布时间:2022-05-24
下一篇:
C# IDisplay类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap