苏preSS第三方库控制台输出? [英] Supress 3rd party library console output?
问题描述
我要打电话,恰好喷出一堆东西到控制台第三方库。在code只是这样的...
I need to call a 3rd party library that happens to spew a bunch of stuff to the console. The code simply like this...
int MyMethod(int a)
{
int b = ThirdPartyLibrary.Transform(a); // spews unwanted console output
return b;
}
有没有一种简单的方法来苏preSS从ThirdPartyLibrary输出不必要的控制台?由于性能的原因,新的进程或线程无法在溶液中使用。
Is there an easy way to supress the unwanted console output from ThirdPartyLibrary? For performance reasons, new processes or threads cannot be used in the solution.
推荐答案
那么你可以使用 Console.SetOut
到的TextWriter 的实现code>不写任何地方:
Well you can use Console.SetOut
to an implementation of TextWriter
which doesn't write anywhere:
Console.SetOut(TextWriter.Null);
这将坐席preSS的所有的控制台输出虽然。你可以始终保持一个参考的原的 Console.Out
作家和使用,为你自己的输出。
That will suppress all console output though. You could always maintain a reference to the original Console.Out
writer and use that for your own output.
这篇关于苏preSS第三方库控制台输出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!