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

C# GCHandle类代码示例

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

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



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

示例1: CreateFirstBridge

	static void CreateFirstBridge () {
		Bridge b = new Bridge() {
			__test = 0,
			id = "first",
		};
		weak_track_handle = GCHandle.Alloc (b, GCHandleType.WeakTrackResurrection);
	}
开发者ID:ItsVeryWindy,项目名称:mono,代码行数:7,代码来源:sgen-bridge-gchandle.cs


示例2: CreateSecondBridge

	static void CreateSecondBridge () {
		Bridge b = new Bridge() {
			__test = 1,
			id = "second",
		};
		weak_track_handle2 = GCHandle.Alloc (b, GCHandleType.WeakTrackResurrection);
	}
开发者ID:ItsVeryWindy,项目名称:mono,代码行数:7,代码来源:sgen-bridge-gchandle.cs


示例3: Update

    void Update()
    {
        if (state == 0) {
            AndroidJavaClass UnityOpenCVLoaderJava = new AndroidJavaClass(UNITY_OPENCV_LOADER);
            var b = UnityOpenCVLoaderJava.CallStatic<Boolean>("isSuccess");
            if (b) {
                state = 1;
            }
        } else if (state == 1) {
            if (cameraInstance == IntPtr.Zero) cameraInstance = CreateCameraInstance ();

            if (Open (cameraInstance, 0, width, height)) {
                texture = new Texture2D (width, height, TextureFormat.ARGB32, false);
                pixels = texture.GetPixels32 ();
                pixelsHandle = GCHandle.Alloc (pixels, GCHandleType.Pinned);
                pixelsPtr = pixelsHandle.AddrOfPinnedObject ();
                GetComponent<Renderer>().material.mainTexture = texture;
                state = 2;
            } else {
                state = -1;
            }
        } else if (state == 2) {
            getCameraTexture (cameraInstance, pixelsPtr, width, height);
            texture.SetPixels32 (pixels);
            texture.Apply ();
        }
    }
开发者ID:rinsyan0518,项目名称:UnityOpenCV,代码行数:27,代码来源:OpenCVCamera.cs


示例4: Update

    // Update is called once per frame
    void Update()
    {
        // off-screen rendering
        var camtex = RenderTexture.GetTemporary (camWidth, camHeight, 24, RenderTextureFormat.Default, RenderTextureReadWrite.Default, 1);
        myCamera.targetTexture = camtex;
        myCamera.Render ();
        RenderTexture.active = camtex;

        tex.ReadPixels (new Rect (0, 0, camtex.width, camtex.height), 0, 0);
        tex.Apply ();

        // Convert texture to ptr
        texturePixels_       = tex.GetPixels32();
        texturePixelsHandle_ = GCHandle.Alloc(texturePixels_, GCHandleType.Pinned);
        texturePixelsPtr_    = texturePixelsHandle_.AddrOfPinnedObject();

        // Show a window
        fullWindow (windowName, displayNum, texturePixelsPtr_, camWidth, camHeight);

        texturePixelsHandle_.Free();

        RenderTexture.active = null;
        RenderTexture.ReleaseTemporary (camtex);
        myCamera.targetTexture = null;
    }
开发者ID:kurepasu0731,项目名称:ProjectionMapping,代码行数:26,代码来源:multiWindow.cs


示例5: DoLoadBank

	private static AKRESULT DoLoadBank(string in_bankPath)
	{
		ms_www = new WWW(in_bankPath);
		while( ! ms_www.isDone )
		{
#if ! UNITY_METRO
			System.Threading.Thread.Sleep(WaitMs);
#endif // #if ! UNITY_METRO
		}

		uint in_uInMemoryBankSize = 0;
		try
		{
			ms_pinnedArray = GCHandle.Alloc(ms_www.bytes, GCHandleType.Pinned);
			ms_pInMemoryBankPtr = ms_pinnedArray.AddrOfPinnedObject();
			in_uInMemoryBankSize = (uint)ms_www.bytes.Length;	
		}
		catch
		{
			return AKRESULT.AK_Fail;
		}
		
		AKRESULT result = AkSoundEngine.LoadBank(ms_pInMemoryBankPtr, in_uInMemoryBankSize, out ms_bankID);
		
		return result;
	}
开发者ID:Arpit0492,项目名称:Unity,代码行数:26,代码来源:AkInMemBankLoader.cs


示例6: CreateBuffer

	private void CreateBuffer(int width, int height)
	{
		// Free buffer if it's too small
		if (_frameHandle.IsAllocated && _frameData != null)
		{
			if (_frameData.Length < _frameWidth * _frameHeight)
			{
				FreeBuffer();
			}
		}
		
		if (_frameData == null)
		{
			_frameWidth = width;
			_frameHeight = height;
			_frameData = new Color32[_frameWidth * _frameHeight];
			_frameHandle = GCHandle.Alloc(_frameData, GCHandleType.Pinned);
			_framePointer = _frameHandle.AddrOfPinnedObject();
			
#if TEXTURETEST
			_testTexture = new Texture2D(_frameWidth ,_frameHeight, TextureFormat.ARGB32, false, false);
			_testTexture.Apply(false, false);
#endif
		}
	}
开发者ID:vovo5558,项目名称:NewScopePlus,代码行数:25,代码来源:AVProLiveCameraGrabber.cs


示例7: Main

    public static int Main()
    {
        int[] arr = new int[1000];
        GCHandle[] arrhandle = new GCHandle[10000]; // array of handles to the same object
        IntPtr[] oldaddress = new IntPtr[10000];        // store old addresses
        IntPtr[] newaddress = new IntPtr[10000];        // store new addresses

        for (int i = 0; i < 10000; i++)
        {
            arrhandle[i] = GCUtil.Alloc(arr, GCHandleType.Pinned);
            oldaddress[i] = GCUtil.AddrOfPinnedObject(arrhandle[i]);
        }

        GC.Collect();
        GC.WaitForPendingFinalizers();

        for (int i = 0; i < 10000; i++)
        {
            newaddress[i] = GCUtil.AddrOfPinnedObject(arrhandle[i]);
        }

        for (int i = 0; i < 10000; i++)
        {
            if (oldaddress[i] != newaddress[i])
            {
                Console.WriteLine("Test failed");
                return 1;
            }
        }

        Console.WriteLine("Test passed");
        return 100;
    }
开发者ID:CheneyWu,项目名称:coreclr,代码行数:33,代码来源:PinnedMultiple.cs


示例8: CreateObj

        public CreateObj()
        {
            obj = new Dummy();
            Console.WriteLine("Allocating a Weak handle to object..");
            handle = GCHandle.Alloc(obj, GCHandleType.Weak);

            // making a copy of the handle
            copy = handle;
        }
开发者ID:CheneyWu,项目名称:coreclr,代码行数:9,代码来源:HandleCopy.cs


示例9: RegisterCommandCallback

    public static void RegisterCommandCallback(CommandCallbackDelegate fun)
    {
        _gcHandle = GCHandle.Alloc(fun);

        if (IntPtr.Size == 8)
            RegisterCommandCallback_x64(fun);
        else
            RegisterCommandCallback_x86(fun);
    }
开发者ID:hhahh2011,项目名称:CH.Study,代码行数:9,代码来源:GoogleV8Engine.cs


示例10: Matrix

    public Matrix(int size)
    {
        if (!_validSizes.Contains(size)) throw new ArgumentOutOfRangeException("size");
        _size = size;
        _data = new int[size * size];

        _dataPtrHandle = GCHandle.Alloc(_data, GCHandleType.Pinned);
        _dataPtr = (int*)_dataPtrHandle.AddrOfPinnedObject().ToPointer();
    }
开发者ID:Farouq,项目名称:semclone,代码行数:9,代码来源:Matrix.cs


示例11: Start

	// Use this for initialization
	void Start () {
        camera_ = getCamera(device);
        setCameraProp(camera_, width, height, fps);
        texture_ = new Texture2D(width, height, TextureFormat.ARGB32, false);
        pixels_ = texture_.GetPixels32();
        pixels_handle_ = GCHandle.Alloc(pixels_, GCHandleType.Pinned);
        pixels_ptr_ = pixels_handle_.AddrOfPinnedObject();
        GetComponent<Renderer>().material.mainTexture = texture_;
    }
开发者ID:kurepasu0731,项目名称:ProjectingLight,代码行数:10,代码来源:WebCamManager_native.cs


示例12: alloc_many

 static void alloc_many()
 {
     int
     small_count
     =
     count
     /
     2;
     GCHandle[]
     more
     =
     new
     GCHandle
     [small_count];
     int
     i;
     for
     (i
     =
     0;
     i
     <
     small_count;
     ++i)
     {
     GCHandleType
     t
     =
     (GCHandleType)
     (i
     &
     3);
     more
     [i]
     =
     GCHandle.Alloc
     (i,
     t);
     }
     for
     (i
     =
     0;
     i
     <
     small_count;
     ++i)
     {
     more
     [i].Free
     ();
     }
     Console.WriteLine
     ("alloc many: {0}",
     small_count);
 }
开发者ID:robertmichaelwalsh,项目名称:Multilex,代码行数:56,代码来源:gchandle-stress.cs


示例13: Cleanup

    private void Cleanup(GCHandle[] argStrHandles, GCHandle argPtrsHandle,
                                       IntPtr gsInstancePtr)
    {
        for (int i = 0; i < argStrHandles.Length; i++)
                argStrHandles[i].Free();

            argPtrsHandle.Free();
            ExitAPI(gsInstancePtr);
            DeleteAPIInstance(gsInstancePtr);
    }
开发者ID:gviaud,项目名称:OS-unity-5,代码行数:10,代码来源:PdfToPng.cs


示例14: GetContextHandle

 public IntPtr GetContextHandle()
 {
     if ((_selfGCHandle.IsAllocated == false))
     {
         _selfGCHandle = GCHandle.Alloc(
                             this,
                             GCHandleType.Normal);
     }
     return GCHandle.ToIntPtr(_selfGCHandle);
 }
开发者ID:niemyjski,项目名称:corert,代码行数:10,代码来源:CallbackContext.cs


示例15: deterministicStaticInit

 private static void deterministicStaticInit()
 {
     __noData = (IntPtr) (-1);
     __defaultCmdSpace = (IntPtr) (-1);
     modFlags = ApiGroup.Off;
     modIdentity = string.Empty;
     ctrlCallback = new CtrlCB(Bid.SetApiGroupBits);
     cookieObject = new BindingCookie();
     hCookie = GCHandle.Alloc(cookieObject, GCHandleType.Pinned);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:10,代码来源:Bid.cs


示例16: UpdateView

		/// <summary>
		/// Update the view. This method triggers the view to be rendered to the
		/// underlaying texture.
		/// </summary>
		/// <returns>true if the view was actually updated</returns>
		public bool UpdateView()
		{
			if (View != null)
			{
				m_DataPin = GCHandle.Alloc(m_Data,
					System.Runtime.InteropServices.GCHandleType.Pinned);

				return View.GetAsBitmap(m_DataPin.AddrOfPinnedObject(),
					Width * Height * 4);
			}
			return false;
		}
开发者ID:Scub3d,项目名称:Aerohacks,代码行数:17,代码来源:MobileSurfaceView.cs


示例17: OnAudioFilterRead

    // Unity audio callback
    public void OnAudioFilterRead(float[] data, int channels)
    {
        if(dataPtr == IntPtr.Zero)
        {
            dataHandle = GCHandle.Alloc(data,GCHandleType.Pinned);
            dataPtr = dataHandle.AddrOfPinnedObject();
        }

        if (islibpdready) {
            LibPD.Process(numberOfTicks, dataPtr, dataPtr);
        }
    }
开发者ID:AVUIs,项目名称:wat,代码行数:13,代码来源:LibPdFilterRead.cs


示例18: Initialize

    void Initialize()
    {
        GStreamer.GUBUnityDebugLogPFN log_handler = null;
        if (Application.isEditor)
        {
            log_handler = (int level, string message) => Debug.logger.Log((LogType)level, "GUB", message);
        }

        GStreamer.Ref("2", log_handler);
        m_instanceHandle = GCHandle.Alloc(this);
        m_Pipeline = new GstUnityBridgePipeline(name + GetInstanceID(), OnFinish, null, null, (System.IntPtr)m_instanceHandle);
    }
开发者ID:xxyz,项目名称:Be-Music-Viewer,代码行数:12,代码来源:GstUnityBridgeCapture.cs


示例19: arwRegisterLogCallback

	public static void arwRegisterLogCallback(LogCallback lcb)
	{
		if (lcb != null) {
			logCallback = lcb;
			logCallbackGCH = GCHandle.Alloc(logCallback); // Does not need to be pinned, see http://stackoverflow.com/a/19866119/316487 
		}
		if (Application.platform == RuntimePlatform.IPhonePlayer) ARNativePluginStatic.arwRegisterLogCallback(logCallback);
		else ARNativePlugin.arwRegisterLogCallback(logCallback);
		if (lcb == null) {
			logCallback = null;
			logCallbackGCH.Free();
		}
	}
开发者ID:mobyjames,项目名称:arunity5,代码行数:13,代码来源:PluginFunctions.cs


示例20: ChannelTexture

    public ChannelTexture(int width, int height, TextureFormat format)
    {
        tex = new Texture2D(width, height, format, false);

        tex.wrapMode = TextureWrapMode.Clamp; //important for NPOT

        #if !((UNITY_ANDROID || UNITY_IPHONE) && !UNITY_EDITOR)
        pixels = tex.GetPixels32(0);
        handle = GCHandle.Alloc(pixels, GCHandleType.Pinned);
        #endif

        ReAlloc();
    }
开发者ID:johannaph,项目名称:nowBabyGit12,代码行数:13,代码来源:MobileMovieTexture.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# GCHandleType类代码示例发布时间:2022-05-24
下一篇:
C# G25类代码示例发布时间: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