|
Heath,
Thanx for your reply. I'm aware of using the "using" statement. The code I posted does what "using" does. It is just more verbose. I also tried using GC.Collect() before and d it didn't do much to help. I think the GC.Collect() is just a hack. you should not have to use it.
I actually ran the code in visual c# express again. it seems to handle it ok. I guess i didn't run it long enough before. Looks like a .NET Framework 1.0 bug with the HttpWebResponse component not collecting properly.
thanx,
amir
|
|
|
|
|
Thank you - I'm very much aware you should run GC.Collect which is why I mentioned you should try it - "try" being the optimal keyword here. The idea was to see if any data was not being released immediately, or if it was just the cached native code after the JIT compilation.
Yes, using equates to a try-finally but you weren't doing this for the HttpWebRequest . using is just short-hand and was only a suggestion to you to make sure that everything - including request objects - were disposed even if an exception was thrown.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
how can i do something like
If (DateTime.Now >= StoredDateTime) ???
i extract the StoredDateTime from database which is save in earlier time useing
DateTime.Now.ToString();
I don't know the setting of time in the machine so i can't expect the returned format .... so how can i accomplish this task..
ADEL K Khalil
|
|
|
|
|
Why are you converting the DateTime to a string. Why not keep it as instance of a DateTime object, you can then use the compare method.
Also, use DateTime.UtcNow, instead of Now - this will ensure that your time is always stored using the same timezone. It's should be quite easy to convert it back to the user's timezone for display purposes.
If your stuck saving it as a string to the database, then you should be able to use the string format objects to control the format it is saved as.
|
|
|
|
|
Chris is right, try to make the structure in your database hold a DateTime object and not a string. If you try to query the database for dates using comparisons other than equals, you'll get unexpected results since it'll be returning rows based on the STRING value of the datetime, not the actual datetime.
Good luck!
|
|
|
|
|
How can you read the Row Height in a DotNet Datagrid?
AeroBatty
|
|
|
|
|
Since all of the cells in a given row will have the same height, you could use the GetCellBounds( rowNum, colNum ).Height to get the height of any row you want. For instance:
dataGrid1.GetCellBounds( 1, 0 ).Height;
would retrieve the height of row 1.
Hopefully that helps you out!
Good luck!
- D
|
|
|
|
|
Hi,
We are in need of some c# tutorials to be written for us. The writers will be reimbursed for the work.
These materials should not be copied from elsewhere. This might be a good opportunity for people who have worked on c# projects for more than a year and want to share their expertise.
If these materials are good enough, this can become a good long term opportunity for these experts.
If interested, please write an email with your interest and expertise level to checker_src@lycos.com or reply to this thread.
Thanks
Muthu
|
|
|
|
|
I want to know some detail about your tutorial, such as what kind of material you need or what is that for, how to organize your tutorial.
Alan Shen
|
|
|
|
|
Can you write an email to my id? My id is checker_src@lycos.com
Thanks for your interest.
|
|
|
|
|
I *might* be interested, but not without knowing what types of tutorials you're looking for, what topics you're interested in, and what it's going to be used for.
Grim (aka Toby) MCDBA, MCSD, MCP+SB
SELECT * FROM user WHERE clue IS NOT NULL
GO
(0 row(s) affected)
|
|
|
|
|
Well we can start with the basic level tutorial. The following is
a rough TOC. If you are interested please send an email to checker_src@lycos.com. It will take 6-12 hrs for me to reply because I might not be having access to external email during office hours. We can discuss the payment and deliverables in emails.
The rates can be discussed. If things are acceptable, it can be a long term opportunity for who can provide original and good content.
TOC:
Each topic should include enough code sample/snippet whichever is applicable. Tutorials should start with compiling the program from command line using csc.exe, then progress to using visual studio.net.
1. Basics of .NET
2. C# basics - compiling code
3. C# data types
4. OOP & C#
5. Intermediate Languate
6. C# Namespaces, classes methods, properties in c#
7. exceptions
8. delegates & events
9. overloading operators
10. Windows Forms - Usage & samples for all controls
11. Controls (I expect the number to be approximately 10-15) Button,
Checkbox, listbox, combobox, menu, grid, Label, Edit control, radio
button, progressbar, tab control, filedialogs, color dialog, tree control,
tool tips.
Also:
ADO.NET - Samples
Printing - samples
After finishing the above, pls do consider the following
intermediate/advanced level topics.
1. Reflection in C#
2. COM Interop
3. Inheritance
4. interfaces
5. Attributes
6. Web services intro
7. Sockets in C# - Server & client
8. Multi-threading in c#
|
|
|
|
|
Greetings,
I am pretty new to console applications (I mostly used to do C# Windows Applications stuff) and I currently need to create a console application for a little personnal project, however, there are a couple of things that I do not know how to do with the console applications.
1- How do I keep a console alive even though the main method has completed?
2- How can I use a function similar to the timer object in a console application?
I really appreciate your time and replies, thank you.
-Vickie
|
|
|
|
|
Vickie,
1. I am not sure about what you called "alive", but I think you can start a process like windows service in main method.
2. as to the timer, here is an example from the help file:
using System;
using System.Threading;
class TimerExampleState
{
public int counter = 0;
public Timer tmr;
}
class App
{
public static void Main()
{
TimerExampleState s = new TimerExampleState();
// Create the delegate that invokes methods for the timer.
TimerCallback timerDelegate = new TimerCallback(CheckStatus);
// Create a timer that waits one second, then invokes every second.
Timer timer = new Timer(timerDelegate, s,1000, 1000);
// Keep a handle to the timer, so it can be disposed.
s.tmr = timer;
// The main thread does nothing until the timer is disposed.
while(s.tmr != null)
Thread.Sleep(0);
Console.WriteLine("Timer example done.");
}
// The following method is called by the timer's delegate.
static void CheckStatus(Object state)
{
TimerExampleState s =(TimerExampleState)state;
s.counter++;
Console.WriteLine("{0} Checking Status {1}.",DateTime.Now.TimeOfDay, s.counter);
if(s.counter == 5)
{
// Shorten the period. Wait 10 seconds to restart the timer.
(s.tmr).Change(10000,100);
Console.WriteLine("changed...");
}
if(s.counter == 10)
{
Console.WriteLine("disposing of timer...");
s.tmr.Dispose();
s.tmr = null;
}
}
}
|
|
|
|
|
Vickie Madigan wrote:
1- How do I keep a console alive even though the main method has completed?
- Don't create other threads as background. The app should stay open as long as at least one non-background thread is alive.
- Start a message loop. Either a form or a service, typically.
- Trick the Main method into not exiting until you want, like this:
class Class1
{
[STAThread]
static void Main(string[] args)
{
while (GlobalFlags.Running);
}
}
internal sealed class GlobalFlags
{
private static bool _running = true;
public static bool Running
{
get {return _running;}
set {_running = value;}
}
}
Vickie Madigan wrote:
2- How can I use a function similar to the timer object in a console application?
Use the System.Timers.Timer object, or a System.Threading.Timer object.
Grim (aka Toby) MCDBA, MCSD, MCP+SB
SELECT * FROM user WHERE clue IS NOT NULL
GO
(0 row(s) affected)
|
|
|
|
|
Well well, this is very CPU-hungry.
|
|
|
|
|
Geez, I assumed you'd know how to make a tight loop not melt the CPU.
Replace while (GlobalFlags.Running); with while (GlobalFlags.Running){System.Threading.Thread.Sleep(100);}
Grim (aka Toby) MCDBA, MCSD, MCP+SB
SELECT * FROM user WHERE clue IS NOT NULL
GO
(0 row(s) affected)
|
|
|
|
|
I need to gather data from an xml document and access it in these ways. I need to show all data in 1 window to start then the user can access each section of the form to view and edit the data via seperate forms. For example a customer has a "Details" section, a "Payment" section, and a "Comments" section. When the user pulls an account up it shows these sections in a window. The comments has many lines of comments, the other 2 have details in drop-downs and labels. When the user opens a menu item to view or edit one of these sections i want another window to open so they can view/edit the info. To sum up the problem i need to collaborate these sections so they are easily obtainable (possibly in a dataset) so i can use the data in both the main form and the sub-forms. any comments appreciated.
|
|
|
|
|
In my windows application,i embed a Com webbrowser control.In DocumentComplete
Event i add thid code:"Event= (HTMLDocumentEvents2_Event)axWebBrowser1.Document;Event.onclick += new mshtml.HTMLDocumentEvents2_onclickEventHandler(ClickEventHandler);" the ClickEventHandler function is defined as :
private bool ClickEventHandler(mshtml.IHTMLEventObj e)
{
MessageBox.Show(e.type + ":" + e.srcElement.tagName);
return true;
}
Now the problem is,when i first load a html file,it work correctly,but when i load a new file again,the MessageBox appear twice,load third file,it appear three time,and so on.So,What can i do to get rid of it,Let the message just appear one time.
I will appreciate you help!
|
|
|
|
|
Hello!
I just installed Microsoft SQL Server Express and it gave me one warning: That IIS was not installed.
I wonder, do I have to have IIS installed to be able to use Microsoft SQL Server Express with Visual studio and C#? I want to create and play with databases, use northwind and so on.
Thanks in advance!
~~~~~~~~~~~~~~
Martin Lundberg
Student, Sweden
I have to thank every member of the Code Project for making it such a great place for a beginner to learn!
|
|
|
|
|
I haven't tried SQL Express, because I already use SQL Server Enterprise, but the System Requirements don't list IIS as a requirement. My thoughts are you don't need it to use the Server. I can't say anything for the SQL Server Tools though. Those MIGHT be web based...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
SQL Server Express is the Yukon version of MSDE, right?
If I'm not mistaken, SQL Server Reporting Services is built into Yukon, instead of being an add-on like it is for 2000. The Reporting Services require IIS to be installed for them to work properly.
Most likely this is the functionality that you won't have because you're missing IIS. There may be something else, I haven't been too worried about getting familiar with Yukon yet.
Grim (aka Toby) MCDBA, MCSD, MCP+SB
SELECT * FROM user WHERE clue IS NOT NULL
GO
(0 row(s) affected)
|
|
|
|
|
Thank you! =)
~~~~~~~~~~~~~~
Martin Lundberg
Student, Sweden
I have to thank every member of the Code Project for making it such a great place for a beginner to learn!
|
|
|
|
|
I am developing a project which features usercontrols like WinForms Controls. I have created controls like text box,picture,etc.,
Each control is a usercontrol and has its own properties.now the problem is when i select the usercontrol i have to get the rectangle that bounds the border of the control when you select a windows control. The user should know which control he/she has selected. Has anyone found a solution for this ?
Thanks in advance
Happy Coding
MankayarKarasi
|
|
|
|
|
You are making your own controls for textbox, picture, etc? Sounds like you're doing a LOT of work when you don't need to be. Either way, a user control should have a Bounds variable, and you can make your own rectangle object with the information the Bounds variable contains.
Mankayarkarasi wrote:
The user should know which control he/she has selected.
I don't understand what you mean here. Are you trying to highlight the controls, or are there overlapped controls where the selected one needs brought to the front? Explain this a little more.
If you need extra functionality for the controls that already exist in C#, it would be a LOT easier for you to create new classes that inherit the old controls...then just add your new functionality.
Hope I helped out at least a little.
Good luck
- D
|
|
|
|