|
Bingo! Perfect.
Thanks to all.
NIK
|
|
|
|
|
Hi
I know multithrading is explained in several tutorials, but I can't figure out how to terminate another thread gracefully. This is my current code. In thread1 when I dispose s I get an error... I realised this would happen with sychronisation etc. What can I do?
public class Loader<br />
{<br />
PNG.SplashScreen s;<br />
Form1 f;<br />
Thread first;<br />
Thread second;<br />
public Loader()<br />
{<br />
first = new Thread(new ThreadStart(thread1));<br />
second = new Thread(new ThreadStart(thread2));<br />
first.Start();<br />
second.Start();<br />
}<br />
void thread1()<br />
{<br />
f = new Form1();<br />
s.Dispose(); <br />
f.ShowDialog();<br />
}<br />
void thread2()<br />
{<br />
s = new PNG.SplashScreen();<br />
s.ShowDialog();<br />
}<br />
}
cheers
|
|
|
|
|
You can't really terminate another thread gracefully. You either kill it ungracefully via someThread.Abort (which injects the ThreadAbortException into the thread being aborted), or you can cancel gracefully by having someThread check for some boolean cancel state over time and exiting when it hits that state.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Goof around music jam with my brothers (with video)
The apostle Paul, modernly speaking: Epistles of Paul
Judah Himango
|
|
|
|
|
You error most probably comes from the fact that it is only safe to alter GUI elements from within the thread they where created in. Have a look at the Invoke[^] method.
|
|
|
|
|
I will appreciate if some can recommend/advice on which book one can get to learn visual C# a Needed the skill to improve ,right now working windows application
|
|
|
|
|
If you go to the store, many books will suffice for starting out. What I definitly would learn is the ADO.NET part, make sure there is enough explanation on that in your book (more than 1 chapter) or buy another one that specifically handles ADO.NET.
Coulda, woulda, shoulda doesn't matter if you don't.
<marquee>
|
|
|
|
|
i have been reading a couple books:
-Microsoft Visual C# 2005 Step By Step
-Visual C#® 2005: How to Program, Second Edition
They are both good books in my opinion
Don't be overcome by evil, but overcome evil with good
|
|
|
|
|
I am new to the programming world.
I will appreciate if some can recommend/advice on which book one can get to learn C# and SQL
Presently, am a systems support engineer on windows platform.Needed the skill to improve on my network infra design.
Any tips/advice on how to learn C# and SQL will be appreciated.
thx
Endless is the Quest for Knowledge
|
|
|
|
|
There are books for learning to become a MCAD (microsoft certified apps dev), but they are actually good beginners books.
For C# / Sql, try Amit Khalani's MCAD 70-616 Training Guide, its really simple, yet gets a lot of info across
just-code-it.net
Managed DirectX & C# Tutorials
|
|
|
|
|
|
Jesse Liberty's "Programming C#" on O'Reilly Press. Get the updated version for .NET 2.0. Its really written for programmers who want to learn C#, rather than people who want to learn how to program using C#. It was the book my C# professor used, and it is a WONDERFUL reference. In addition, anyting in the Microsoft .NET Development Series helps. I have their books on ADO.NET and data binding in windows forms.
Also, the articles here on codeproject are great too. I've definetely used a couple to learn what I need to overcome some issues I've had.
Good luck.
-- modified at 16:45 Tuesday 30th May, 2006
On Amazon:
Programming C#[^]
OR
Learning C#[^] if you think that might be better.
|
|
|
|
|
I design a messenger like hotmail and yahoo. i connect with hotmail server but face some problem in fetching address book which are added in my messenger. can any body help me for this problem the tool i using is c#
thanks
from Musharaf
|
|
|
|
|
Can anyone help me with this small problem, The cell position of a ListView is worked out by the mouse_click x,y and the width of the columns. Is there any way to account for the hidden portion of the control when a form is resized and a scroll bar introduced?
i.e.
Example problem with incorrect x,y co-ordinates due to scrollbar offset.[^]
Any help would be appreciated, thanks
Darren
|
|
|
|
|
Are you using ListViewItem.Bounds ?
|
|
|
|
|
No, the problem is before i need the bounds of the SubItem i need to work out which SubItem it is... using the folowing MouseDown event handler i get the current x,y position of the mouse relevant to the form but it does not account for the 'actual' size of the listview, only the visible portion (or maybe gives me x,y from top-left of the form overall not sure). So somehow i need to get access to the correct size of the ListView irrelevant to the size of the form.
public void EAL_MouseDown(object sender, MouseEventArgs e)
{
li = this.GetItemAt(e.X , e.Y);
X = e.X ;
Y = e.Y ;
}
I found this article: http://www.codeproject.com/cs/miscctrl/CSharpHitTest.asp
and it has some interesting comments on the horizontal scrollbar problem, gonna chase them up.
Thanks
Darren
|
|
|
|
|
How do I catch for e.g. a <ctrl> + s (User want to save) to my Form (C#).
_____________________________
...and justice for all
APe
|
|
|
|
|
If you want to add a shortcut key combination to an event handler you could look at the:
System.Windows.Forms.Shortcut. pre defined set.
such as:
System.Windows.Forms.Shortcut.CtrlS; for Ctrl + S.
if you wanted to add this to an event handler for a menu bar for e.g. you would do this for an Exit item with Ctrl + X as shortcut keys:
Menu.MenuItems.Add(new MenuItem("E&xit", new EventHandler(this.FileExit_Clicked), Shortcut.CtrlX));
where FileExit_Clicked is your event handling method.
|
|
|
|
|
If you want to catch Ctrl+S you can override ProcessCmdKey in your Form derived class, like this...
protected override bool ProcessCmdKey ( ref Message msg, Keys keyData )
{
const int WM_KEYDOWN = 0x100;
if ( msg.Msg == WM_KEYDOWN && keyData == ( Keys.Control | Keys.S ) )
{
MessageBox.Show("You have pressed Ctrl+S");
return true;
}
return base.ProcessCmdKey( ref msg, keyData );
} Hope that helps
“Accept that some days you are the pigeon, and some days you are the statue” -- David Brent
Cheers,
Will
|
|
|
|
|
That made it!! Thanks!
_____________________________
...and justice for all
APe
|
|
|
|
|
The DataSet doesn't serialize its DataRelationship collection in my test case! In .NET 1.1, the docs clearly show the [Serializable] attribute, and in .NET 2.0, the docs have it missing!
What happened to being able to serialize the DataSet's relationships???
[edit]You have to set the "Nested" property of the DataRelation for it to serialize correctly with WriteXml.[/edit]
Marc
Pensieve
Some people believe what the bible says. Literally. At least [with Wikipedia] you have the chance to correct the wiki -- Jörgen Sigvardsson
-- modified at 13:53 Tuesday 30th May, 2006
|
|
|
|
|
I'm kinda new to database programming in C#, so bear with me. I've done a search in my MSDN library documentation, and I've done a quick search through CP's articles, both to no avail. Can someone please tell me how to create a new mdb file from inside my code? (or point me in the right direction, to some informative article somewhere)
At the present time, I'm stuck making my mdb files in MS Access and then playing with them in code, but I'd like to create a new one from my code...
Thanks!
-Daniel
Typing too fast fro my owngood
|
|
|
|
|
Hi Daniel,
This was taken from here: http://www.dotnet247.com/247reference/msgs/11/59426.aspx
1. Open a new Visual C# .NET console application.
2. In the Solution Explorer window, right-click the References node and select
Add Reference.
3. In the Add Reference dialog box, click the COM tab and select Microsoft ADO
Ext. 2.7 for DDL and Security. Click Select to add it to the "Selected
Components". Click OK.
4. Delete all of the code from the code window for Class1.cs.
5. Copy the following code and paste it into the code window:
using System;
using ADOX;
namespace ConsoleApplication1
{
class Class1
{
[STAThread]
static void Main(string[] args)
{
ADOX.CatalogClass cat = new ADOX.CatalogClass();
cat.Create("Provider=Microsoft.Jet.OLEDB.4.0;" +
"Data Source=D:\\AccessDB\\NewMDB.mdb;" +
"Jet OLEDB:Engine Type=5");
Console.WriteLine("Database Created Successfully");
cat = null;
}
}
}
6. Change the path to the new .mdb file as appropriate. Press F5 to build and
run the project.
The new .mdb file will be created in Access 2000 (Jet 4.0) format. For a
different Jet format, see "References."
|
|
|
|
|
Cool, thanks!
I'm working on a project that I'm developing outside of VisualStudio (just using Notepad, Paint, and csc.exe... it's a long story). I was hoping to find something closer to System.Easy (like in the System.Data.Odbc area), but from what I've learned about database programming so far, I think they decided that easy wasn't a top priority.
I just might migrate this project into VisualStudio after all...
Thanks for the tip, Darren!
-Daniel
Typing too fast fro my owngood
|
|
|
|
|
Heritos Gger wrote: just using Notepad, Paint, and csc.exe
You should try SciTE which has a very small footprint and also offers syntax highlighting for C#. Plus you can bind csc to a menu item / the Build / Compile Command.
You know you're a Land Rover owner when the best route from point A to point B is through the mud.
Ed
|
|
|
|
|
if you have a generic abstract class:
public abstract AbstractClass<T>
Who's derivative classes declare the type like:
public DerivedClass1 : AbstractClass<int>
public DerivedClass2 : AbstractClass<bool>
How would get a third class to except objects of AbstractClass type no matter what T was:
public class NewClass
{
private AbstractClass myField;
}
Because as I understand it now, I would have to set a type on AbstractClass in the field definition. Obviously I could set the type as object, but that would defeat the who purpose. Is there a way to do this and retain type safety or am I going about this implementation all wrong?
|
|
|
|