473,800 Members | 2,414 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Console.Foregro undColor per thread getting jumbled.

Aju
lock (o)
{
Console.Foregro undColor =
(ConsoleColor)E num.Parse(typeo f(ConsoleColor) ,
Attributes["ConsoleCol or"]);
Console.Write(m essage);
Console.ResetCo lor();
}

I hoped each thread would get it's own color based on an external
parameter that's set at load time. However, ocassionlly outputs means
to be in green are coming out in red and so on.

Any ideas?
Jun 27 '08 #1
1 1532
Well, I was going to say "add some locking"... so: what is "o"
here...? not everything is suitable for locking... and it must be the
same reference over all threads - the following would suffice:

public static class SharedLock {
public static readonly object Lock = new object();
}

then lock(SharedLock .Lock) {...}

Marc

Jun 27 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
5388
by: Oz | last post by:
This is long. Bear with me, as I will really go through all the convoluted stuff that shows there is a problem with streams (at least when used to redirect stdout). The basic idea is that my application (VB.NET) will start a process, redirect its stdout and capture that process' output, displaying it in a window. I've written a component for this, and a test application for the component. It allows me to specify a command to execute,...
5
2342
by: Glenn | last post by:
Hi! Server info - Win2K3 Server +SP1 with 1 GB Memory and 1.5 GB Virtual Memory SQL Server 2000 Enterprise Edition + SP3 running on this. Required result - Create a SQL Script that will contain a set of create, update, insert & delete statements (about 17500 lines including blank lines) that
1
5201
by: Kevin | last post by:
In a newsgroup thread from Jan 8, 2003 between Barry Holsinger and the VBDotNet Team, please review this excerpt: "You understood my problem completely. Your sample code provides a really elegant way to inject CrLf into the input stream, which effectively unblocks the ReadLine method. Last night, I had finally got the WriteConsoleInput
1
2046
by: John Wright | last post by:
I am running a console application that connects to an Access database (8 million rows) and converts it to a text file and then cleans and compacts the database. When it runs I get the following error: The CLR has been unable to transition from COM context 0x1a2008 to COM context 0x1a2178 for 60 seconds. The thread that owns the destination context/apartment is most likely either doing a non pumping wait or processing a very long...
2
7672
by: nautonnier | last post by:
Hello, I have a C# app that spawns several processes each containing a console app written by another developer in C++. The console app was written first to be just like a console app: it starts, you type a command it does a command and returns a message. I thought I would be able to consume it in my C# app by using the Process.StandardInput in conjunction with the Process.StartInfo.RedirectStandardOutput. The output works fine and I...
1
2394
by: not_a_commie | last post by:
How do you send an escape key to the console? I was trying to change the color of the text in cmd.exe with something like this: Console.Out.Write("\u001b[1;31m"); But that doesn't seem to have any effect. I also tried 001b. Any ideas?
5
1455
by: Amzin | last post by:
Hello. I'm writing roguelike using VB.NET. It has very slow console output. Is there any methods to make it work faster? For example, Sub PlaceAt(ByVal s As String, ByVal x As Integer, ByVal y As Integer) Console.SetCursorPosition(x, y) Console.Write(s) End Sub
4
223
by: =?Utf-8?B?UGFvbG8=?= | last post by:
Is there a way of accessing the various graphics characters to facilitate drawing on the screen in console apps. I don't want to use the '-' (hyphen) character - I thoughtthere were some 'graphics' characters hat were available. I've looked at the Console Class specs and can't find anything about this. Any advice would be appreciated. Thanks
1
1608
by: =?iso-8859-1?B?S2VyZW0gR/xtcvxrY/w=?= | last post by:
Hi, how can i fill a consoles background with complete green color? The ForegroundColor member only fills the written buffers background, but i need to fill the complete consoles background buffer with green color. How can i do this? I guess this can be made with some API Pinvoke, but which one?
0
9690
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10033
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9085
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7576
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6811
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5471
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5606
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3764
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2945
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.