본문 바로가기

2017/05

(12)
[c#] 경과 시간을 표시할 때 String saveTempString = string.empty;DateTime tempDateTime = DateTime.Now; // 시작하는 위치 ... 처리 로직 TimeSpan diff = DateTime.Now - tempDateTime; saveTempString = string.Format("{0:hh\\:mm\\:ss}", diff); Console.WriteLine(saveTempString);
[c#] StreamWriter 로 텍스트 파일 생성/쓰기 StreamWriter 로 텍스트 파일 생성/쓰기 public static void SaveFile(string filePath, string saveData = null) { if (!File.Exists(filePath)) { using (StreamWriter sw = File.CreateText(filePath)) { sw.Write(saveData); sw.AutoFlush = true; } } else { using (StreamWriter sw = File.AppendText(filePath)) { sw.Write("\r\n" + saveData); sw.AutoFlush = true; } } } 참조 : StreamWriter MSDN
[c#][Linq][Entityframework] ContextSwitchDeadlock occurred ContextSwitchDeadlock occurredMessage: Managed Debugging Assistant 'ContextSwitchDeadlock' has detected a problem in 'C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO 12.0\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\TESTWINDOW\vstest.executionengine.x86.exe'.Additional information: CLR에서 60초 동안 COM 컨텍스트 0xd58440에서 COM 컨텍스트 0xd584f8(으)로 전환하지 못했습니다. 대상 컨텍스트/아파트를 소유하는 스레드가 펌프 대기를 수행하지 않거나, Windows 메시지를 펌프..
[c#][Linq][EntityFramework] 메모리 누수 방지를 위한 Skip, Take 사용방법 int totalCount = 0;int amountToSkip = 0;int processAmount = 0;Boolean finished = false; using(var context = new {{DataContext}}()){ totalCount = context.{{테이블}}.Where({{조건절}}).Count(); while (!finished) { resultList = context.{{테이블}} .Where({{조건절}}) .OrderBy({{정렬조건}}) //Skip, Take 사용을 위해 정렬 필수 .Skip(amountToSkip) .Take(1000).ToList(); //Take 수는 적절히 조정 processAmount = resultList.Count; if (result..