本文整理汇总了C#中System.Diagnostics.TextWriterTraceListener.Write方法的典型用法代码示例。如果您正苦于以下问题:C# TextWriterTraceListener.Write方法的具体用法?C# TextWriterTraceListener.Write怎么用?C# TextWriterTraceListener.Write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Diagnostics.TextWriterTraceListener
的用法示例。
在下文中一共展示了TextWriterTraceListener.Write方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: App
/// <summary>
/// Application initializer. Performs compatibility check,
/// starts diagnostics if required, works settings around,
/// and initializes the process of generating of internal data structures.
/// </summary>
public App()
{
if(Util.OsIs.VistaExact) //If run on shit
{
MessageBox.Show(
Power8.Properties.Resources.Err_VistaDetected,
Power8.Properties.NoLoc.Stg_AppShortName, MessageBoxButton.OK, MessageBoxImage.Error);
Environment.Exit(2); //means: OS not found
}
//Global error mode setter - in 1st place to fix nasty startup error on Win10x86
API.SetErrorMode(API.ErrMode.FailCriticalErrors);
//Power8s in our session but with different pid
foreach (var p in Process.GetProcessesByName("Power8")
.Where(p => p.SessionId == Proc.SessionId && p.Id != Proc.Id))
{
p.Kill();
}
Util.MainDisp = Dispatcher; //store main thread dispatcher. Widely used in Application.
#if DEBUG
//System.Threading.Thread.CurrentThread.CurrentUICulture = System.Globalization.CultureInfo.GetCultureInfo("ru");
//Error handling and detection
var l = new TextWriterTraceListener(Environment.ExpandEnvironmentVariables(@"%temp%\p8log.txt"));
l.Write("\r\n\r\nPower8 Log opened at " + DateTime.Now + "\r\n\r\n");
Debug.AutoFlush = true;
Debug.Listeners.Add(l);
#endif
DispatcherUnhandledException += (sender, e) => Util.DispatchUnhandledException(e.Exception);
AppDomain.CurrentDomain.UnhandledException += HandleUnhandled;
var dbRoot = Util.GetSettingsIndependentDbRoot();
try
{
var ids = Directory.GetFiles(dbRoot, "*" + ClientIDExtension);
string clientId;
if (ids.Length == 0)
{
clientId = Guid.NewGuid().ToString();
File.Create(dbRoot + "\\" + clientId + ClientIDExtension);
}
else
{
clientId = Path.GetFileNameWithoutExtension(ids[0]);
}
Analytics.Init(TrackID, clientId, Power8.Properties.NoLoc.Stg_AppShortName,
Util.GetAppVersion().ToString());
}
catch (Exception ex)
{
Log.Raw("Unable to read client ID to init analytics: " + ex);
}
//Move settings from previous ver
var std = Power8.Properties.Settings.Default;
if (!std.FirstRunDone)
{
try
{
std.Upgrade();
}
catch (Exception ex)
{
Log.Raw("Unable to upgrade settings: " + ex);
}
std.Save();//FirstRunDone is updated later in Main Window code
Analytics.PostEvent(Analytics.Category.Deploy, std.FirstRunDone ? "Update" : "Fresh", null, 1);
}
//Initialize standard folder icon
ImageManager.GetImageContainerSync(new PowerItem { Argument = dbRoot, IsFolder = true }, API.Shgfi.SMALLICON);
//Build tree
Util.ForkPool(PowerItemTree.InitTree, "InitTree");
//react on DwmCompositionChanged event
ComponentDispatcher.ThreadFilterMessage += WndProc;
}