|
Process.GetCurrentProcess().Threads.Count
I don't see what good that will do, though. You're code isn't the only code starting threads. Windows applications use many threads in the background as needed.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
hi,
Heath i have a doubt. When we run an application i mean a standalone .exe. is this perticular exe is comming in one appdomin or not ?
********************
S r e e j i t h N a i r
Bangalore - India
********************
|
|
|
|
|
There are only a few reasons why anyone should embrace asycronous response patterns and this doesn't appear to be one of them. You should design the batch processing into the SQL server instead of in the client application.
You should avoid it if possible because it makes problems more complex. Trying to do this "mixed mode" thing becomes a nightmare. You should either keep everything syncronized or asycronous because bridging between causes all sorts of fun issues (like race conditions and deadlocks). Simple tasks like deleting rows become much harder. If you want to delete, you must syncronize against the asycronous handle you setup elsewhere to do insertions. If you want to exit you have to syncronize against the asycronous handle you setup elsewhere to do insertions. Heck even adding rows you will have to be careful.
Asycronous programming is not for the faint of heart which is why I constantly recommend against using it unless you have to. The point of a SQL server is to keep transactions sane and syncronized. Why thawart this?
|
|
|
|
|
Hi,
Is it possible to port the code developed in C# on to a Solaris machine??
Is there any cross platform product that makes it possible??
If somebody has idea how to do it, please reply.
Regards,
Satya
|
|
|
|
|
Mono[^]
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way!
|
|
|
|
|
Hi,
I want to use C# features and port it to Sun Platform, is this possible??
Regards,
Satya
|
|
|
|
|
|
Hy everyone!
Yeah, shame on me, but it seems I actually do have a blackout , although this should be something of C#s basics:
I do have two clases
<br />
public class Key<br />
{<br />
public int keyId;<br />
public string telephoneNo;<br />
}<br />
public class Telephone<br />
{<br />
public Key[] keys;<br />
public string telephoneId;<br />
}<br />
o.k. that's it. But now I do want to create an array of Telephoneobjects (Lentgth 1) - which of course contains the telephoneId field - which contains an array of Keyobjects - which of course contains the keyId and the telephoneNo.
This finally should allow the following assignment for example
<br />
mynumbers[0].telephoneId="12345";<br />
mynumbers[0].keys[0].keyId=12;<br />
mynumbers[0].telephoneNo="12345";<br />
Yes, I know I should have known myself but I guess I do have kind of blackout at the moment!
Thanks for your patience for helping to get rid of my blackout!
Stephan.
|
|
|
|
|
Telephone[] telephones = new Telephone[1];
telephones[0] = new Telephone();
Also, you should not declare fields as public , it violates the encapsulation rules in Object Oriented design. You should wrap the behaviour in properies instead - this allows you to change the internal structure of the class without modifying the external interfaces.
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way!
|
|
|
|
|
oh well, then my blackout was thinking it was wrong what I was doing!
Thanks for your help!
Stephan.
|
|
|
|
|
Does anyone knows how to write a c# program to convert a *.wav ( wave ) file to a midi file...?
|
|
|
|
|
Short answer: I don't know.
Long answer:
Wave files are "recordings" of sounds using digital samples of the audio waveform amplitude. At the risk of oversimplifying, they're essentially a series of numbers, and if you draw a graph of those numbers you'll see a waveform that looks just like the sound would look on an oscilliscope.
MIDI files consist of instructions for synthesized musical instruments, such as "press the C key on the piano softly, wait a quarter of a second, then release it".
A wav to midi conversion program would need to be able to look at a waveform and determine not only what note is being played, but how loudly and by which type of instrument, and to distinguish the sounds of multiple instruments playing at the same time, potentially mixed with sound effects, vocals, etc., any of which may not be able to be represented in MIDI format.
Despite those difficulties such programs do exist. Sort of. Search for "convert wav to midi" on Google to find some of them and to read more about this complicated subject.
This doesn't answer your question, though, which is how to do it in C#. I don't know the answer to that.
|
|
|
|
|
Why constructors don't return values ??
|
|
|
|
|
Because constructors are called when a new class is created, and therefore what is returned to the caller is a new instance of the class.
"A people that values its privileges above its principles soon loses both." -- Dwight D. Eisenhower
|
|
|
|
|
As an extra to the previous answer, if you want to inicate that something in the constructor did not work as expected, throw an exception, that or provide an extra initialisation function for use after the object was constructed.
"Je pense, donc je mange." - Rene Descartes 1689 - Just before his mother put his tea on the table.
Shameless Plug - Distributed Database Transactions in .NET using COM+
|
|
|
|
|
i draw some rectangles and lines into the the panel object. but how can i save the content in the panel object to a bitmap file ?
thanks....:
|
|
|
|
|
If you want to keep what you've drawn to your panel, then I guess you'll have to take a different approach altogether.
Am I right that you're calling myPanel.CreateGraphics() and then use this Graphics object for painting? In this case, the actions are not recorded anywhere and your panel will be blank after the next paint event it receives (try hiding your panel behind another window and then restoring it...).
I think you should use a Bitmap from the start and paint onto this Bitmap using a Graphics object retrieved by Graphics.FromImage() .
In the paint event handler of your panel you paint the bitmap.
That way you can also call myBitmap.Save(...) to save the contents of the bitmap.
Regards,
mav
|
|
|
|
|
What 'mav' said will work, but there's several problems with his approach. If you draw on a Graphics object that you obtained from Control.CreateGraphics , your elements will be drawn. But if the form needs repainting (perhaps it was covered up by another form), they won't be redrawn. You need to perform your drawing in an override of OnPaint (which is passed a PaintEventArgs that has a Graphics property that you should use for painting).
In order to be able to save that same code to a Bitmap class and then to a file, you'll want to modularize your code like so:
private void PaintRectangles(Graphics g)
{
g.DrawRectangle(...);
}
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
PaintRectangles(e.Graphics);
}
private void saveBtn_Click(object sender, EventArgs e)
{
using (Bitmap bmp = new Bitmap(panel1.Size.Width,
panel1.Size.Height))
{
using (Graphics g = Graphics.FromImage(bmp))
{
PaintRectangles(g);
}
bmp.Save("filename.png", ImageFormat.Png);
}
} Now you've encapsulated your rectangle drawing code into a single method that can draw onto any Graphics object, including the form or panel itself (this is only an example, mind you) or a Bitmap . The using statements above make sure that both the Bitmap and Graphics objects are disposed (very important, otherwise memory may not be freed when necessary and unmanaged objects will linger, causing memory leaks) even if an exception is thrown.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi,
I'm improving the GUI of my demo program. There are some controls in the UI, like textbox and numericUpDown etc. I just want to highlight the text (fullly select the text) when I tabbing them.
now, I just using the Control's Enter event handler for each control, and then do selection inside its function.
I felt quite inconvenient, especially, when using numericUpDown, I need to do selection by using this command :
numericUpDown1.Select(0, numericUpDown1.Value.ToString().Length);
so, Is there any easy way to do this?
thanks
|
|
|
|
|
Some of the controls such as TextBox have .SelectAll() method but some like numericUpDown don't. But if you want that behaivor for all of your controls you could go with mass selection of them all and then handling their's .Enter event.
<br />
Control[] GetAllControls() <br />
{<br />
ArrayList list = new ArrayList();<br />
GetAllControls(Controls, list);<br />
return (Control[])list.ToArray(typeof(Control));<br />
}<br />
void GetAllControls(Control.ControlCollection controls, ArrayList list)<br />
{<br />
foreach(Control control in controls) {<br />
if(control.HasChildren) GetAllControls(control.Controls, list);<br />
list.Add(control);<br />
}<br />
}<br />
<br />
void Form_Load(object sender, System.EventArgs e)<br />
{<br />
foreach (Control c in GetAllControls())<br />
c.Enter += new EventHandler(c_Enter);<br />
}<br />
<br />
void c_Enter(object sender, EventArgs e)<br />
{<br />
if (c is TextBox)<br />
((TextBox)c).Select(0, c.Text.Length);<br />
}<br />
To make it easier you could detect Base classes (for TextBox it is BaseTextBox)... if someone has better solution please correct me...
|
|
|
|
|
hi,
im developing an application that needs to POST (multipart) unicode texts to the server.
i tried to send unicode directly to the server and it throws a "ProtocolViolation" exception.
now, i have to convert every char to integer and then to string.
any easier way to do it?
thanks
|
|
|
|
|
You might want to take a look at the System.Text.Encoding class, which can encode and decode strings and byte[] arrays to/from different encodings (even particular code pages, which don't apply to Unicode). Make sure you also set the HttpWebRequest.ContentEncoding to the proper type, or for multipart-MIME the particular Content-Type (and charset) for a MIME part. In either case, the Encoding class will help.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
What is the way to create fast links from highlighted words in a richTextBox to certain parts in text of this or other's richTextBoxes?
I want to have an available description of some highlighted items in richTextBoxes when the user clicks on them.
|
|
|
|
|
There's a LinkClicked event available which you'll have to handle.
By default, standard links (beginning with http:// or ftp:// and a few others) are displayed as links and fire the event when clicked.
If you want other parts (esp. not starting with <protocol>://) then you'll have to use interop to set the correct character attribute (CFE_LINK) to the text range you want to act as a link.
You might use this article on MSDN as a basis for extending your RichTextBox to add support for something like SetSelectionLink() .
Regards,
mav
|
|
|
|
|
....................................<br />
richTextBox1.LinkClicked += new LinkClickedEventHandler(Link_Clicked);<br />
................................................<br />
protected void Link_Clicked(object sender, LinkClickedEventArgs e)<br />
{<br />
.................................................<br />
}
Could someone tells me how: when click on an item in the richTexBox1 to display a specific area of the richTextBox1 ?
Thank you mav.northwind for your response.
Could I have a more specific answer?
|
|
|
|