示例#1
0
        private static void ConnectTransport()
        {
            if (IsTransportConnected)
            {
                throw new System.InvalidOperationException(SR.Get(SRID.MediaSystem_OutOfOrderConnectOrDisconnect));
            }

            //
            // Create a default transport to be used by this media system.
            // If creation fails, fall back to a local transport.
            //

            HRESULT.Check(UnsafeNativeMethods.WgxConnection_Create(
                              false, // false means asynchronous transport
                              out s_pConnection));

            // Create service channel used by global glyph cache. This channel is
            // the first channel created for the app, and by creating it with
            // a null channel reference it creates a new partition.
            // All subsequent channel creates will pass in a reference to this
            // channel thus using its partition.
            s_serviceChannel = new DUCE.Channel(
                null,
                false,       // not out of band
                s_pConnection,
                false);

            IsTransportConnected = true;
        }
示例#2
0
            internal DUCE.Channel AllocateSyncChannel()
            {
                DUCE.Channel syncChannel;

                if (_pSyncConnection == IntPtr.Zero)
                {
                    HRESULT.Check(UnsafeNativeMethods.WgxConnection_Create(
                                      true, // true means synchronous transport
                                      out _pSyncConnection));
                }

                if (_freeSyncChannels == null)
                {
                    //
                    // Ensure the free sync channels queue...
                    //

                    _freeSyncChannels = new Queue <DUCE.Channel>(3);
                }

                if (_freeSyncChannels.Count > 0)
                {
                    //
                    // If there is a free sync channel in the queue, we're done:
                    //

                    return(_freeSyncChannels.Dequeue());
                }
                else
                {
                    //
                    // Otherwise, create a new channel. We will try to cache it
                    // when the ReleaseSyncChannel call is made. Also ensure the
                    // synchronous service channel and glyph cache.
                    //

                    if (_syncServiceChannel == null)
                    {
                        _syncServiceChannel = new DUCE.Channel(
                            null,
                            false,      // not out of band
                            _pSyncConnection,
                            true        // synchronous
                            );
                    }

                    syncChannel = new DUCE.Channel(
                        _syncServiceChannel,
                        false,      // not out of band
                        _pSyncConnection,
                        true        // synchronous
                        );

                    return(syncChannel);
                }
            }