private void procEventLoop() { while (m_stop == false) { SpinWait.SpinUntil(() => listEventData.Count > 0 || m_stop == true, -1); if (m_stop == true) { break; } if (listEventData.Count > 0) { //取得第一筆資料 CEventInfo _cTaskInof = new CEventInfo(4294967295);///初始化UInt32最大值 Monitor.Enter(listEventData); _cTaskInof = listEventData[0]; listEventData.RemoveAt(0); if (_cTaskInof == null) { continue; } Monitor.Enter(listEventData); InvokeDelegate fnProcThis; try { if (listProcFuncitons.TryGetValue(_cTaskInof.nEventCode, out fnProcThis)) { Thread thProcEvent = new Thread(() => fnProcThis(_cTaskInof)); thProcEvent.SetApartmentState(ApartmentState.STA); //Set the thread to STA thProcEvent.Start(); } else { CDebug.jmsg("[錯誤]處理事件:{0}未設定處理函式\n", _cTaskInof.nEventCode); continue; } } catch (Exception e) { CDebug.jmsgEx("[EventPorc]Exception!!{0}", e.Message); continue; } } } }
public static MemoryStream BitmapStreamResize(MemoryStream IntputStream, double Scale) { if (IntputStream != null && Scale > 0) { try { Bitmap OriginImg = new Bitmap(IntputStream); return(BitmapStreamResize(OriginImg, Scale)); } catch { CDebug.jmsgEx("BitmapStreamResize Stream Error"); return(null); } } else { CDebug.jmsgEx("BitmapStreamResize Parameter Error"); return(null); } }
public static MemoryStream BitmapStreamResize(Bitmap IntputBitmap, double Scale) { if (IntputBitmap != null && Scale > 0 && IntputBitmap.Width > 0 && IntputBitmap.Height > 0) { try { Bitmap ResizeImg = ResizeProcess(IntputBitmap, IntputBitmap.Width, IntputBitmap.Height, (int)(IntputBitmap.Width * Scale), (int)(IntputBitmap.Height * Scale)); MemoryStream ResizeStream = new MemoryStream(); ResizeImg.Save(ResizeStream, System.Drawing.Imaging.ImageFormat.Png); return(ResizeStream); } catch { CDebug.jmsgEx("BitmapStreamResize Transfer Error"); return(null); } } else { CDebug.jmsgEx("BitmapStreamResize Parameter Error"); return(null); } }