|
Make a .cmd file and put this in it
<yourappname>
echo %ERRORLEVEL%
pause
then double click the .cmd file
"Just about every question you've asked over the last 3-4 days has been "urgent". Perhaps a little planning would be helpful?" Colin Angus Mackay in the C# forum
led mike
|
|
|
|
|
Thank you very much for your help.
|
|
|
|
|
I am new to C# and have a class project to work on. I am trying to create an Amortization calulator the display the payment results based on the Time period thay have to repay the loan. The calculation part of it is working fine but I can not get it to display the result. Can I please get some help with this? See code Below:
<script runat="server">
protected void Button1_Click(object sender, EventArgs e)
{
Label6.Text = "Final Balance: " +
CalculateBalance(Convert.ToInt32(TextBox1.Text),
(Convert.ToDouble(TextBox2.Text) / 100),
Convert.ToInt32(TextBox3.Text),
Convert.ToInt16(DropDownList1.SelectedItem.Value)).ToString();
}
private string CalculateBalance(int Principal, double Rate, int Years, int Period)
{
double result;
double NumToBeRaised = (1 + Rate / Period);
result=Principal * System.Math.Pow(NumToBeRaised, (Years * Period));
return (result.ToString("C"));
}
private string AmortDisplay(double Principal, double results, int Years, int Period)
{
int AmortTime;
double AmortPayment;
double RemBalance;
string Output;
AmortTime = (Years * Period);
AmortPayment = (results / AmortTime);
RemBalance = -(Principal - AmortPayment);
TextBox4.Text = "Duration\t \tPayment\t \tRemaining Balance \n" + AmortTime + "\t\t" + Convert.ToString(AmortPayment) + "\t\t" + Convert.ToString(RemBalance) + "\n";
}
protected void Button2_Click(object sender, EventArgs e)
{
AmortDisplay(Convert.ToDouble(TextBox1.Text),
Convert.ToDouble(Label6.Text),
Convert.ToInt32(TextBox3.Text),
Convert.ToInt16(DropDownList1.SelectedItem.Value)).ToString();
}
</script>
ext="Principal ($)" Width="165px" BackColor="Transparent" Font-Size="Medium"></asp:Label>
<asp:TextBox ID="TextBox1" runat="server" Style="position: relative" BackColor="Silver"></asp:TextBox><br />
<br />
<asp:Label ID="Label3" runat="server" Style="position: relative" Text="Rate (%)" Width="165px" BackColor="Transparent" Font-Size="Medium"></asp:Label>
<asp:TextBox ID="TextBox2" runat="server" Style="position: relative" BackColor="Silver" TabIndex="1"></asp:TextBox>
<br />
<br />
<asp:Label ID="Label4" runat="server" Style="position: relative" Text="Years:" Width="165px" BackColor="Transparent" Font-Size="Medium"></asp:Label>
<asp:TextBox ID="TextBox3" runat="server" Style="position: relative" BackColor="Silver" TabIndex="2"></asp:TextBox><br />
<br />
<asp:Label ID="Label5" runat="server" Style="position: relative" Text="Compound Frequency:" Width="165px" BackColor="Transparent" Font-Size="Medium"></asp:Label>
<asp:DropDownList ID="DropDownList1" runat="server" Style="position: relative" BackColor="Silver" TabIndex="3">
<asp:ListItem Value="1">Annually</asp:ListItem>
<asp:ListItem Value="4">Quarterly</asp:ListItem>
<asp:ListItem Value="12">Monthly</asp:ListItem>
<asp:ListItem Value="365">Daily</asp:ListItem>
<asp:ListItem></asp:ListItem>
</asp:DropDownList><br />
<br />
<asp:Button ID="Button1" runat="server" Style="left: 9px; position: relative; top: 10px"
Text="Calculate" Width="207px" OnClick="Button1_Click" BackColor="Silver" TabIndex="4" Font-Size="Medium" /><br />
<br />
<br />
<br />
<asp:Label ID="Label6" runat="server" Style="position: relative" Width="165px"></asp:Label> <br />
<asp:TextBox ID="TextBox4" runat="server" Height="345px" Style="position: relative"
Width="871px"></asp:TextBox>
Greg
The Belizean Dan Dada!!!
|
|
|
|
|
Of course it doesn't display any result. You don't have any code that displays the result.
---
b { font-weight: normal; }
|
|
|
|
|
Hello,
If I have a method of type
public void myMethod()
{
}
And I create a delegate void NewDelegate(void)
What is the actual difference between the following calls and how they are handled by .NET and the OS
NewDelegate del = NewDelegate(myMethod);
del.BeginInvoke(null, null);
and
Thread t = new Thread(new ThreadStart(myMethod));
t.Start();
I know the delegate will use a thread from the thread pool, but will the thread t as well? What is the actual effect of one versus the other.
|
|
|
|
|
Calling BeginInvoke on a delegate makes the method execute on a thread from the CLR's thread pool. You can't get a refernce to that thread, so you don't have fine-grained control over it.
:josh:
My WPF Blog[^]
|
|
|
|
|
So at the end it's only the reference issue? So if I launch some form on the thread, and then close the form. Does my thread (BeginInvoke or Thread.Start) returns to the thread pool?
Another thing, if I need my thread to be STA, I must create a new instane of the thread, and then set the ApartmentStyle. Meaning I can't use Delegate.BeginInvoke. Right?
|
|
|
|
|
zaboboa wrote: So at the end it's only the reference issue? So if I launch some form on the thread, and then close the form. Does my thread (BeginInvoke or Thread.Start) returns to the thread pool?
A background thread will keep running unless you kill it or the UI thread is killed (i.e. close the app).
zaboboa wrote: Another thing, if I need my thread to be STA, I must create a new instane of the thread, and then set the ApartmentStyle. Meaning I can't use Delegate.BeginInvoke. Right?
I don't know.
:josh:
My WPF Blog[^]
|
|
|
|
|
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[^]
|
|
|
|