From c09f307a79759e8bd43881c818b2f4c5c82e1b75 Mon Sep 17 00:00:00 2001 From: lxmou666 <772765102@qq.com> Date: Mon, 28 Dec 2020 17:38:42 +0800 Subject: [PATCH] 1 --- .../TRTC/ViewModels/LiveWindowViewModel.cs | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/JianGongYun/TRTC/ViewModels/LiveWindowViewModel.cs b/JianGongYun/TRTC/ViewModels/LiveWindowViewModel.cs index 7acbadc..0b72bea 100644 --- a/JianGongYun/TRTC/ViewModels/LiveWindowViewModel.cs +++ b/JianGongYun/TRTC/ViewModels/LiveWindowViewModel.cs @@ -178,9 +178,11 @@ namespace JianGongYun.TRTC.ViewModels } } + + static object ScreenListLock = new object(); private SIZE thumbSize = new SIZE { cx = 300, cy = 200 }; private SIZE iconSize = new SIZE { cx = 50, cy = 50 }; - private ObservableCollection _LiveScreens = new ObservableCollection(); + private ObservableCollection _LiveScreens; /// /// 可分享桌面 /// @@ -188,17 +190,20 @@ namespace JianGongYun.TRTC.ViewModels { get { - _LiveScreens.Clear(); - var temp = LiveClassroom.lTRTCCloud.getScreenCaptureSources(ref thumbSize, ref iconSize); - var count = temp.getCount(); - for (uint i = 0; i < count; i++) + lock (ScreenListLock) { - var info = temp.getSourceInfo(i); - //var icon = Util.ToWriteableBitmap(ref info.iconBGRA); - var thumb = info.thumbBGRA.ToWriteableBitmap(); - _LiveScreens.Add(new TRTCScreenEntity { SourceId = info.sourceId, SourceName = info.sourceName, Type = info.type, Thumb = thumb, Info = info }); + _LiveScreens.Clear(); + var temp = LiveClassroom.lTRTCCloud.getScreenCaptureSources(ref thumbSize, ref iconSize); + var count = temp.getCount(); + for (uint i = 0; i < count; i++) + { + var info = temp.getSourceInfo(i); + //var icon = Util.ToWriteableBitmap(ref info.iconBGRA); + var thumb = info.thumbBGRA.ToWriteableBitmap(); + _LiveScreens.Add(new TRTCScreenEntity { SourceId = info.sourceId, SourceName = info.sourceName, Type = info.type, Thumb = thumb, Info = info }); + } + temp.release(); } - temp.release(); return _LiveScreens; } }