/// <summary> /// 接收 /// </summary> public void receive() { string filename = frm.fileNames[ThreadId]; // 线程临时文件 byte[] buffer = new byte[_bufferSize]; // 接收缓冲区 int readSize = 0; // 接收字节数 FileStream fs = new FileStream(filename, System.IO.FileMode.Create); Stream ns = null; Console.WriteLine("线程[" + ThreadId.ToString() + "] 开始接收......"); try { HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Url); request.AddRange(frm.StartPos[ThreadId], frm.StartPos[ThreadId] + frm.fileSize[ThreadId]); ns = request.GetResponse().GetResponseStream(); readSize = ns.Read(buffer, 0, _bufferSize); Console.WriteLine("线程[" + ThreadId.ToString() + "] 正在接收 " + readSize); while (readSize > 0) { fs.Write(buffer, 0, readSize); readSize = ns.Read(buffer, 0, _bufferSize); // Console.WriteLine("线程[" + ThreadId.ToString() + "] 正在接收 " + readSize); } fs.Close(); ns.Close(); } catch (Exception er) { MessageBox.Show(er.Message); fs.Close(); } Console.WriteLine("进程[" + ThreadId.ToString() + "] 结束!"); frm.threadStatus[ThreadId] = true; }
protected virtual void doWork() { ThreadState = System.Threading.ThreadState.Running; m_SimpleMethod(); ThreadState = System.Threading.ThreadState.Stopped; if (threadCallback != null) { threadCallback(ThreadId.ToString()); } }
protected virtual void doWorkP(object parms) { ThreadState = System.Threading.ThreadState.Running; m_ParamMethod(parms); ThreadState = System.Threading.ThreadState.Stopped; if (threadCallback != null) { threadCallback(ThreadId.ToString()); } }
public void Log(string logInfo) { if (_logUtility == null) { _logUtility = new LogUtility(); } string str = string.Format("Thread {0}: {1}", ThreadId.ToString(), logInfo); _logUtility.Log(str); }
public override string ToString() { return(string.Format(DefaultNumberedMessageFormat, ThreadHashCode.ToString(), ThreadId.ToString(), ApplicationName, ProcessId, Utc.ToShortDateString(), Utc.ToShortTimeString(), Message)); }
public override string ToString() { var t = ThreadId.ToString(); if (t.Length == 1) { t = $"{t} "; } return($"[{t}] {Message}"); }
public void Save() { Query savePost = new Query("INSERT INTO POSTS (thread_id, subject, message, poster, image) VALUES(@ThreadId, @Subject, @Message, @Poster, @Image)"); savePost.AddParameter("@ThreadId", ThreadId.ToString()); savePost.AddParameter("@Subject", Subject); savePost.AddParameter("@Message", Message); savePost.AddParameter("@Poster", Poster); savePost.AddParameter("@Image", Image); savePost.Execute(); Console.WriteLine("SUBJECT: " + Subject); }
public void Save() { Query savePost = new Query("INSERT INTO POSTS (thread_id, subject, message, date, author, avatar) VALUES(@ThreadId, @Subject, @Message, @Date, @Author, @Avatar)"); savePost.AddParameter("@ThreadId", ThreadId.ToString()); savePost.AddParameter("@Subject", Subject); savePost.AddParameter("@Message", Message); savePost.AddParameter("@Date", Date); savePost.AddParameter("@Author", Author); savePost.AddParameter("@Avatar", Avatar); savePost.Execute(); Id = (int)savePost.GetCommand().LastInsertedId; savePost.Close(); }
public override string ToString() { object names = new { ThreadHashCode = ThreadHashCode.ToString(), ThreadId = ThreadId.ToString(), ApplicationName = ApplicationName, ProcessId = ProcessId.ToString(), UtcShortDate = Utc.ToShortDateString(), UtcShortTime = Utc.ToShortTimeString(), Message = Message }; return(NamedMessageFormat.NamedFormat(names)); }
/// <summary> /// Creates a new store on the remote node. /// </summary> /// <param name="threadId">The ID of the database.</param> /// <param name="name"></param> /// <param name="cancellationToken">The token to monitor for cancellation requests. The default value is <see cref="CancellationToken.None"/>.</param> /// <returns></returns> public async Task <ThreadId> NewDBAsync(ThreadId threadId, string name = null, CancellationToken cancellationToken = default) { ThreadId dbId = threadId ?? ThreadId.FromRandom(); NewDBRequest request = new() { DbID = ByteString.CopyFrom(dbId.Bytes) }; if (!string.IsNullOrEmpty(name)) { _threadContext.WithThreadName(name); request.Name = name; } await _apiClient.NewDBAsync(request, headers : _threadContext.WithThread(dbId.ToString()).Metadata, cancellationToken : cancellationToken); return(dbId); }
public void Format(LogEvent logEvent, TextWriter output) { try { var(Category, Application, Identity, ClassType, MethodName, ActivityId, ProcessId, ThreadId, Stacktrace, Properties) = Helper.ExtractEventInfo(logEvent); using (var properties = new StringWriter()) using (var messageText = new StringWriter()) { MessageFormatter.Format(logEvent, messageText); PropertyFormatter.Format(Properties, properties); // Output the text. output.WriteLine(string.Format("{0} {1} {2} {3} {4} {5} {6} {7} - {8} - {9} - {10}", logEvent.Timestamp.ToString("dd/MM/yyyy HH:mm:ss,fff").PadRight(24), MessageLogLevelMap[logEvent.Level].PadRight(13), MessageCategoryMap[Category].PadRight(14), Identity.PadRight(15), ProcessId.ToString().PadRight(6), ThreadId.ToString().PadRight(6), ActivityId.PadRight(40), ClassType, MethodName, messageText.ToString(), properties.ToString())); if (null != logEvent.Exception) { output.Write(logEvent.Exception.ToFormattedString()); } if (!String.IsNullOrWhiteSpace(Stacktrace)) { output.WriteLine(Stacktrace); } } } catch (Exception) { } }
public String BuildString(MessageMode mode) { switch (mode) { case MessageMode.DateThreadMessage: return(String.Format("[{0}]-Thread[{1}]: {2}", CreateTime.ToLongTimeString(), ThreadId.ToString(), Message)); default: return(Message); } }
/// <summary> /// 返回表示当前对象的字符串 /// </summary> /// <returns></returns> public override string ToString( ) { if (string.IsNullOrEmpty(KeyWord)) { return($"[{Degree}] {Time.ToString( "yyyy-MM-dd HH:mm:ss.fff" )} Thread [{ThreadId.ToString( "D2" )}] {Text}"); } else { return($"[{Degree}] {Time.ToString( "yyyy-MM-dd HH:mm:ss.fff" )} Thread [{ThreadId.ToString( "D2" )}] {KeyWord} : {Text}"); } }
/// <summary> /// 返回表示当前对象的字符串,剔除了关键字 /// </summary> /// <returns></returns> public string ToStringWithoutKeyword() { return($"[{Degree}] {Time.ToString( "yyyy-MM-dd HH:mm:ss.fff" )} Thread [{ThreadId.ToString( "D2" )}] {Text}"); }
public override string ToString() { string[] headerData = new string[] { GetDateTimeString(Time), BackgroundTaskId, ThreadId.ToString(), Name }; return(string.Join("\n", headerData.Concat(Data))); }
/// <summary> /// 获取本日志消息的字符串表示形式 /// </summary> /// <returns></returns> public override string ToString( ) { return($"[{Degree}] {Time.ToString( "yyyy-MM-dd HH:mm:ss.fff" )} Thread [{ThreadId.ToString( "D2" )}] {Text}"); }
/// <summary> /// /// </summary> /// <returns></returns> public override string ToString() { return(ThreadId.ToString(CultureInfo.InvariantCulture)); }
/// <summary> /// 返回表示当前对象的字符串,剔除了关键字 /// </summary> /// <returns>字符串信息</returns> public string ToStringWithoutKeyword( ) { if (Degree != CommonMessageDegree.None) { return($"[{Degree}] {Time.ToString( "yyyy-MM-dd HH:mm:ss.fff" )} Thread [{ThreadId.ToString( "D3" )}] {Text}"); } else { return(Text); } }
/// <summary> /// 返回表示当前对象的字符串 /// </summary> /// <returns>字符串信息</returns> public override string ToString( ) { if (Degree != CommonMessageDegree.None) { if (string.IsNullOrEmpty(KeyWord)) { return($"[{Degree}] {Time.ToString( "yyyy-MM-dd HH:mm:ss.fff" )} Thread [{ThreadId.ToString( "D3" )}] {Text}"); } else { return($"[{Degree}] {Time.ToString( "yyyy-MM-dd HH:mm:ss.fff" )} Thread [{ThreadId.ToString( "D3" )}] {KeyWord} : {Text}"); } } else { return(Text); } }
public override string ToString() { return ($"{TraceIndicator}[{Level.ToString().ToUpperInvariant()}][{Timestamp}][Thread {ThreadId.ToString().PadLeft(4, '0')}] {Message}"); }
public override string ToString() => $"On thread (name: [{ThreadName}]) with id [{ThreadId.ToString()}] at [{TimeStamp:O}], " + $"exception of type [{Error.GetType().Name}] was thrown.";
public override string ToString() { return(ThreadId.ToString()); }
/// <summary> /// Returns a <see cref="System.String" /> that represents this LogEvent. /// </summary> /// <returns>A <see cref="System.String" /> that represents this LogEvent.</returns> public override string ToString() { return ($"[{Level.ToString().ToUpperInvariant()}][{Timestamp}][Thread {ThreadId.ToString().PadLeft(4, '0')}][{LogSource}] {Message}"); }