|
George_George wrote: I can not find any related information from MSDN about the thread safety of this method.
Not directly, but it can be worked out from the documentation.
Console.WriteLine is a wrapper for Console.Out.WriteLine. Console.Out is an instance of a TextReader, and in the documentation for TextReader it says: "Thread Safety Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe."
|
|
|
|
|
So great, Colin!
regards,
George
|
|
|
|
|
|
Thanks Dave,
Your reply is very clear.
regards,
George
|
|
|
|
|
Hi All
I am using ICSharpCode.SharpZipLib.FastZip to unzip files we receive over the internet in C#.NET2. The problem I am having is that some of the zipped files we receive contains folders with the files we want in those folders. What I need is for it to unzip the files in the zipped folder directly to the 'target directory'.
I.e.
C:\zippedfiles.zip //Contains - "folder\zippedfile.txt"
//When unzipping it, I need it to be
C:\zippedfile.txt
//NOT
C:\folder\zippedfile.txt
That's it. Any help would be great, thanks in advance.
Kiefie
The man with a plan...now where'd that plan go?
|
|
|
|
|
Hello i am working with a chat in c# and there´s one thing left to do, a list of members who are in the chat, in a listbox. tried for hours but i am not comming anywhere so now i am asking for help.. so please can some one help me //Bobbziz
Waddatah
|
|
|
|
|
If you are using a client server approach, you would probably be best off if you made a function to retrieve a list of the users from the server.
|
|
|
|
|
Hey i trying to make a application thats run on background and write to a file how long user was running a application
Ex.
if user click on word then write to a file user clict on word time: 11:01 or somthing like that.
and if user clickt on internet explorer then write to file user clickt on internet explorer time: 11-03.
i hope you can help me.
Sorry my english,
|
|
|
|
|
|
thanks very much dave.. i was wery big help.
but how shut i get the application name which user has clict on.
thanks very mutch
|
|
|
|
|
Not sure - I just came accross that article the other day when searching for info for someone else!
This one[^] captures the App name so you should be able to figure it out from the source.
Don't forget to use the CP search function - that's how I found them
Dave
|
|
|
|
|
I was creating my tray icon for a console application using NotifyIcon Class adn it is working fine (it creates the icon)
However it dosent seem to run the event handlers (click events) on the icon..
Please guide me..
Here is my simple test program which dosent run the mouse events..
class Program
{
static void Main(string[] args)
{
Program p = new Program();
p.MyMethod();
}
void MyMethod()
{
NotifyIcon tray = new NotifyIcon();
tray.Icon = new Icon("MyIcon.ico");
tray.Visible = true;
tray.MouseClick += new MouseEventHandler(tray_MouseClick);
tray.Click += new EventHandler(tray_Click);
tray.DoubleClick += new EventHandler(tray_DoubleClick);
Console.Read();
}
public void tray_MouseClick(object sender, MouseEventArgs e)
{
Process.Start(@"C:\Windows\Notepad");
Console.WriteLine("Hello World!");
}
public void tray_Click(object sender, EventArgs e)
{
Console.WriteLine("Hello World!");
}
public void tray_DoubleClick(object sender, EventArgs e)
{
Console.WriteLine("Hello World!");
}
}
|
|
|
|
|
Where is your Application.Run ?
|
|
|
|
|
leppie wrote: Where is your Application.Run?
This is just a test to see whether on clicking the icon, the "Hello World" is printed to the console..
This is not a forms application, this is a console application.
I put a breakpoint on the code in the tray_MouseClick, trayClick, and tray_DoubleClick and it dosent hit the break points..
|
|
|
|
|
ptr2void wrote: This is not a forms application, this is a console application.
I know that, but how the hell is a Winform control suppose to respond if your app does not have a friggen message loop????
Thats why you need Application.Run . It will not work any other way.
|
|
|
|
|
tray.Click += new System.EventHandler(this.notifyIcon1_Click);
tray.MouseClick += new System.Windows.Forms.MouseEventHandler(this.notifyIcon1_MouseClick);
tray.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.notifyIcon1_MouseDoubleClick);
|
|
|
|
|
Abhijit Jana wrote: tray.Click += new System.EventHandler(this.notifyIcon1_Click); tray.MouseClick += new System.Windows.Forms.MouseEventHandler(this.notifyIcon1_MouseClick); tray.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.notifyIcon1_MouseDoubleClick);
hi, thanks for the answer, but it still dosent seem to work..
Here is my edited code, but still of no use..
static void Main(string[] args)
{
Program p = new Program();
p.MyMethod();
Console.Read();
}
void MyMethod()
{
NotifyIcon tray = new NotifyIcon();
tray.Icon = new Icon("Mcafee.ico");
tray.Visible = true;
tray.MouseClick += new System.Windows.Forms.MouseEventHandler(this.tray_MouseClick);
tray.Click += new EventHandler(this.tray_Click);
tray.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.tray_DoubleClick);
}
public void tray_MouseClick(object sender, MouseEventArgs e)
{
Process.Start(@"C:\Windows\Notepad");
Console.WriteLine("Hello World!");
}
public void tray_Click(object sender, EventArgs e)
{
MessageBox.Show("Hi");
}
public void tray_DoubleClick(object sender, EventArgs e)
{
Console.WriteLine("Hello World!");
}
|
|
|
|
|
are you getting any error ?
|
|
|
|
|
No I am not getting any errors..
The application is running fine waiting for my input (Console.ReadLine)..
But when I click the icon in the system tray, nothing happens..
I even tried adding breakpoints at the starting brace of the three methods: tray_MouseClick, tray_Click, tray_DoubleClick
But these breakpoints are never hit.
|
|
|
|
|
ok, let me check, i will back when done !!
Thanks
|
|
|
|
|
do one thing.
Do the same program in windows. Then Check the Designer.Cs Code.
|
|
|
|
|
Thanks abhijit for the answer, but yaar this icon needs to be for a console application only..
I am developing a console application and want a notify icon for an console application and not a windows form.
I'd really appreciate if anyone could help me out.
|
|
|
|
|
|
I don't often write console apps so if this is incorrect - someone please point it out!
Although you can create a notify icon in a console app, I don't believe you can interact with it from one.
I think one way to do this is to launch an invisible winforms app that handles the notify icon and attach the console app's process to it so the winforms app can redirect the output.
Alternatively, you may be able to do some Pinvoke[^] stuff to catch the messages.
Dave
|
|
|
|
|
Okay, this doesn't work because a console application is not event driven. It just sits there and waits, when its waiting for your input its because you called the method Read or ReadLine otherwise it wouldn't know you had pressed any keys.
Windows applications listen for messages that the OS sends it, so when you click something the OS will send a message to the application which contains information on what what was clicked, where, with what button etc. To use these messages you need to use Application.Run otherwise the OS will not send any messages to your application (or the application will ignore them, either way).
My current favourite word is: I'm starting to run out of fav. words!
-SK Genius
Game Programming articles start - here[ ^]-
|
|
|
|