|
It isn't just a reference issue, see my other post for details. Also look at this page from MSDN: About Thread Pools[^]. There is a section at the bottom entitled "Best Practices" that sums things up nicely.
As regards your second question about apartment models, according to the following quote from another part of MSDN, you cannot use a thread pool thread in STA:
"Each thread uses the default stack size, runs at the default priority, and is in the multithreaded apartment."
Hope that helps!
Sincerely,
Alexander Wiseman
|
|
|
|
|
Hello,
First, as a general answer to your question about threading, take a look at this web-page[^]. It is long, but well worth the read.
Jon Skeet (the author of that document) speaks of the difference between thread pool threads and threads created with ThreadStart . The main difference is that thread pool threads are already created and waiting for a job to execute. This means that it is faster to use a thread from the thread pool to do a task. That does not mean it is better, by any means. Mr. Skeet recommends (and I think this is wise) that you use threads from the thread pool if you have a short, quick task that you would like to be multithreaded, but that you should never use thread pool threads to perform long operations. Using threads from the thread pool for long operations is a bad idea because other applications need access to the threads as well. Also, the Framework itself uses threads from the threads pool, so it is bad idea to tie them up for a long time. If the Framework needs a thread and they are all involved in long tasks, then bad things can happen to your application.
To sum up: if you have long tasks to be accomplished by other threads, use ThreadStart without a doubt. The extra time and resources it takes to create a new thread will not matter so much. If you have quick and easy tasks which need to be accomplished by other threads, use a thread pool thread.
Hope that helps!
Sincerely,
Alexander Wiseman
|
|
|
|
|
Thank you very much guys for all your replies.
It was very helpfull.
|
|
|
|
|
Hi all,
Is it possible to inherit from an enumtype eg. System.TypeCode??
Thx..
|
|
|
|
|
|
Has anybody ever tried to paint a single pixel? Best I can do is draw a line two pixels long. I never have figured out how to accomplish that.
Try code model generation tools at BoneSoft.com.
|
|
|
|
|
There's a SetPixel method.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
On Bitmap yes, but I can't find a way through the graphics class. Just seems strange to me that they didn't include a way to do it there.
Try code model generation tools at BoneSoft.com.
|
|
|
|
|
What about calling DrawRectangle on a rect that is 1x1 ?
:josh:
My WPF Blog[^]
|
|
|
|
|
Don't remember if I tried that, but I know you can't draw a line that's one pixel long. I assume rectangle will fail too. I'll try it out though.
Try code model generation tools at BoneSoft.com.
|
|
|
|
|
Try to draw small dotted line.
Try to draw circle with rect 1x1.
Or finally, set cliprect with size 1x1, and draw line (very bad solution, if upper methods does't work).
Best regards, Alexey.
|
|
|
|
|
Hi all
i want to use Console.Beep() in vs.net 2003 as it is new in 2005
what can i do?
haitham
|
|
|
|
|
You can't. That is a .NET 2.0 feature, so you cannot use it from .NET 1.x code.
:josh:
My WPF Blog[^]
|
|
|
|
|
I think you will have to use P/Invoke code to get to the Win32 Beep call.
PInvoke.net[^]
Steve Maier, MCSD MCAD MCTS
|
|
|
|
|
Do it the old-fashioned way:
Console.WriteLine("\a");
Logifusion[^]
|
|
|
|
|
That didn't work for me, in a WinForms app. Does that require some system volume setting to be non-muted?
:josh:
My WPF Blog[^]
|
|
|
|
|
Put it in a console app. It's a standard PC speaker beep, not a windows beep.
Logifusion[^]
|
|
|
|
|
Hi All
when I am trying to discover visual studio 2005, I got a strange behavior when I am trying to put about 50 button on the form and run the application it makes some flicking in the startup
I don't know why?
|
|
|
|
|
This is due to progressive redrawing of parts of a displayed surface. u can use buffering to avoid this flickering.
see Control.DoubleBuffered Property. set this one into true.
|
|
|
|
|
Thx, I tried this , DoubleBuffered is protected property and should be used in the sub class
I made an inherited class from class button and used it in my form instead of class Button
see this
class InheritedButton:Button
{
public InheritedButton()
{
this.DoubleBuffered = true;
}
}
but it is still flickers????
|
|
|
|
|
Use SetStyle(); and set it in the control that the buttons are getting added to. Also, if you are doing the adding of buttons, instead of the designer, then you should do the following:
public void LoadButtons(string[] buttontext)
{
this.SuspendLayout();
...
this.ResumeLayout();
}
-- modified at 10:03 Thursday 13th July, 2006
|
|
|
|
|
i did but still got the problem
public frmMain()
{
InitializeComponent();
this.SetStyle(ControlStyles.UserPaint, true);
this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
LoadButtons();
}
private void LoadButtons()
{
panContainer.SuspendLayout();
this.SuspendLayout();
for (int j = 0; j < 50; j++)
{
InheritedButton TempButton = new InheritedButton();
TempButton.Cursor = System.Windows.Forms.Cursors.Hand;
TempButton.Size = CellSize;
TempButton.TabStop = false;
TempButton.Text = "?";
TempButton.UseVisualStyleBackColor = true;
TempButton.Click += new System.EventHandler(this.button_ClickGenralHandler);
//TempButton.Location //Coding For locations
panContainer.Controls.Add(TempButton);
}
panContainer.ResumeLayout(false);
this.ResumeLayout(false);
}
and this the code of the Inhireted Controls
class InheritedButton:Button
{
public InheritedButton()
{
this.SetStyle(ControlStyles.UserPaint, true);
this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
}
}
class InheritedPanel : Panel
{
public InheritedPanel()
{
this.SetStyle(ControlStyles.UserPaint, true);
this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
}
}
i still got the problem
|
|
|
|
|
IP-GATES OFFERS MCSE CCNA BOOT CAMP TRAINING IN INDIA/GOA
MCSE CCNA CCNP MCSD VB.NET RHCE CHECKPOINT CCSE CCSP
COST EFFECTIVE .A STUDY AND HOLIDAY EXPERIENCE
IP-GATES (IT TRAINING TRUSTED GLOBALLY)
http://www.ipgates.com[^]
IP-GATES (IT TRAINING TRUSTED GLOBALLY)
http://www.ipgates.com
|
|
|
|
|
Too cheap to buy an ad on CodeProject, huh?
What part of "Do not posts ads in the programming forums" do you not understand?
ipgates wrote: IP-GATES (IT TRAINING TRUSTED GLOBALLY)
Except at the CodeProject, and any other site you spammed with this garbage.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|