|
Adding to my previous reply:
you may find it difficult to organize the looping in a single form; the natural solution
is to have two form classes, the main one organizing the looping (and maybe showing highest
scores, or whatever), the second one representing a single game.
So now the app would:
create and show a main form,
then loop over the following steps {
create a game form,
show it (maybe as a dialog) (and maybe you want to temporarily hide the main form)
let the game run,
when the game is done, make mainform visible again (if hidden), and close the game form
}
As I said before you could reuse the game form (by hiding, not closing it), but I
see no real advantage here, since now you must reinitialize the game form explicitly
for consecutive runs of the game.
|
|
|
|
|
of course you are Right ,and i did what you said when the user finish close the game form an return to the main form .
but i do not want to return to the main form again after finishing the game , i want the game form to reshow again as if it reloaded ,that is the problem .
Mona
LA ELAH ELA ALLAH MOHAMED RASOL ALLAH
|
|
|
|
|
The main form can organize that without being visible.
And as I said before, the game form can either be reused or be replaced by a new
instance (that would cause some flickering I guess).
|
|
|
|
|
Hi Mona,
you do one thing.....
Create one function which loads the form and then recall it .
example---------
MessageBox.Show("Are you want to play Again??????","Play Game",MessageBoxButtons.YesNo)==DialogResult.Yes)
{
///call the functio here...........
}
Nisar Inamdar
|
|
|
|
|
thank you Nisar Inamdar for your replay .
i do a method witch create an instant from the form and call it and hide the current form ,and it works .
but i have a question when i hide the current form every time the user win or lose the form still exists ,do you think that is over load in memory , and bad performance , i do not know i am asking
thanks again for your Useful Replay
Mona ,
LA ELAH ELA ALLAH MOHAMED RASOL ALLAH
|
|
|
|
|
I believe you can do a Form.Close() and then a Form.Dispose() in order to clean up the memory, instead of having the form stick around w/ Form.Hide.
|
|
|
|
|
Hello,
As the Close method allready calls Dispose, the additional Dispose call is not usefull and could also lead to an Exception!If the GC is faster then you
All the best,
Martin
|
|
|
|
|
I wanna do something like
Dictionary<string, object=""> params = new Dictionary<string, object="">
string[] a = new string[10];
params.Add("Array",a);
CallWcfService(a);
It throws an error saying
Type 'System.String[]' with data contract name 'ArrayOfstring:http://schemas.microsoft.com/2003/10/Serialization/Arrays' is not expected. Add any types not known statically to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding them to the list of known types passed to DataContractSerializer.
Any help?
- Projjal
|
|
|
|
|
Erhm, using .NET Framework 2.0 using a dictionary would look something like this :
<br />
Dictionary<string, string> myDict = new Dictionary<string, string>();<br />
myDict.Add("stringvalue", "stringvalue");<br />
|
|
|
|
|
I am reading strong name signing in .NET world. say I am developing dlls to distribute,
example1.dll I will get a strongname file using sn -k example1.snk, test example1.dll using its public key and sign it with private key when ready to release.
When I work on the second dll, example2.dll I will do the same thing - example2.snk, am I right that the private keys are different? Does it make sense in te same comapny,the private key should be kept the same(and secret) and the public keys change? Is there anyway to retrieve a private key from a .snk file?
Thanks
|
|
|
|
|
The strong name key used only really matters in a few instances. It can be used to set up a new category for security settings, so that assemblies from a given manufacturer can be given higher than normal privileges (e.g. to allow access to local files by name if running from a network drive). It must also be used in building Publisher Policy assemblies used to force clients of old versions of an assembly to a newer version of the assembly - this is to ensure that only the original publisher can do this.
The strong naming keys are a pair - one public key corresponds to one private key and no other. In general, one organization should use the same strong naming key for all applications. In some cases, you may want to reserve the private key for a final release step, to protect it from being accidentally used or used maliciously. In this case, use sn -p to extract the public key and save it to a separate file. Distribute the public key to your developers and secure the original key file which contains both keys. Developers then use the /delaysign option so that the compiler leaves space for the signature in the file, and records the full name of the assembly. They will need to use sn -Vr to suppress verification for that assembly or public key token, otherwise the Framework will refuse to load the assembly. You then need to use sn -R to re-sign the assembly, using the private key, for distribution.
However, BY FAR the simplest approach is NOT to use strong naming and simply make private copies of shared assemblies in each application which uses them. The GAC is overused, in my opinion - only those assemblies which really must be shared should go in the GAC. If you're not intending to place the assembly in the GAC you should not strong-name the assembly, because the Framework uses different location rules for strong-named versus private assemblies.
|
|
|
|
|
In one connection i want to take two sqlcommands cmd1 and cmd2 is it possible ??????????????
srinivas
|
|
|
|
|
hi,
yes...............
you can do it...............
nisar inamdar
|
|
|
|
|
It depends on your database, .NET Framework version, and connection string.
In any version of SQL Server and .NET Framework, you can execute as many commands as you like on one connection, as long as you close the first data reader before opening the next one. In SQL Server 2000, and .NET Framework 1.1 connecting to SQL Server 2005, you cannot execute any commands when you have a SqlDataReader open on the same connection. If using .NET Framework 2.0 with SQL Server 2005, you can use a new feature called Multiple Active Result Sets (MARS). The connection string option to control this is called MultipleActiveResultSets. It's enabled by default, but it does use more resources on the server.
If you execute commands on different connections, SQL Server will consider them as commands from different clients and you can end up blocking or deadlocking your own code.
It's generally recommended to keep connections open for the minimum time possible - the length of a transaction, which is recommended to be short. If connection pooling is turned on (as it is by default) you will normally still get back a connection object that is still actually connected to the server, so you don't pay the cost of connecting to the server again.
|
|
|
|
|
Hi
I have one rdlc report. It has one text field and one datafield.
I want to show both in report viewer but when I print this report only datafield print .....
Please replay as soon as posible...
Thanks in advance...........
hi...
|
|
|
|
|
Hi All,
I'm after a little guidance regarding SQL database access in C#.
I come from a VB6 background and rightly or wrongly the way i was shown database access with ADO was to open a global connection at the beginning, use it throughout the program and close it down at the end or if a problem occurred.
I understand now that keeping a connection open for the whole time is wrong but i would like to understand what the correct way in C# is.
At the moment i have created a single static connection in a static class and i've set the ConnectionString property at the very beginning though i don't open the connection. Then throughout the program i open the connection, perform the work and then close it afterwards.
Now, should i be doing it this way or should i be creating a new connection at every point where database access is required ? I take it that as long as the ConnectionString remains unchanged (Maybe using a static string to hold the connectionstring), a connection will be taken from the pool??
Is there a preferred or 'Best Practice' way of accessing a database throughout a program?
Thanks in advance.
Matt.
|
|
|
|
|
matbuk wrote: I understand now that keeping a connection open for the whole time is wrong but i would like to understand what the correct way in C# is.
In .NET, not just C#, the guidelines suggest that you open a connection, perform your query and then close the connection. If you have multiple queries to perform in quick succession then you may keep the connection open for those queries.
.NET implements connection pooling so there is negligible performance hit after the connection is opened for the first time. Just ensure that each time you open a connection you use the exact same connection string.
matbuk wrote: Then throughout the program i open the connection, perform the work and then close it afterwards.
Sounds good to me.
matbuk wrote: Now, should i be doing it this way or should i be creating a new connection at every point where database access is required ? I take it that as long as the ConnectionString remains unchanged (Maybe using a static string to hold the connectionstring), a connection will be taken from the pool??
I, personally, use new connection objects but keep the connection string the same.
matbuk wrote: Is there a preferred or 'Best Practice' way of accessing a database throughout a program?
Create a DAL through which you access your database. Don't put database code in the presentation layer.
Upcoming events:
* Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ...
"I wouldn't say boo to a goose. I'm not a coward, I just realise that it would be largely pointless."
Ready to Give up - Your help will be much appreciated.
My website
|
|
|
|
|
Thanks for your very quick response, i have a couple more questions if i may.
If i create a DAL class would i then create an new instance at every point where data access was required? Secondly, if i returned something like a DataSet from the DAL, whould the connection remain open?
Thanks,
Matt.
|
|
|
|
|
matbuk wrote: If i create a DAL class would i then create an new instance at every point where data access was required?
I typically make my DAL classes singletons. It gets created on the first use and then reused throughout.
matbuk wrote: Secondly, if i returned something like a DataSet from the DAL, whould the connection remain open?
DataSets are not connected to the database. So you can safely close the connection once you have the data and return a dataset.
Upcoming events:
* Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ...
"I wouldn't say boo to a goose. I'm not a coward, I just realise that it would be largely pointless."
Ready to Give up - Your help will be much appreciated.
My website
|
|
|
|
|
Excellent. Thanks for your help.
I found this, is this a good place to start?
http://www.codeproject.com/cs/database/SqlWrapper.asp
|
|
|
|
|
Hello,
Does anyone know how can i generate the code to copy one class to another ? the class is not seralizable.
I was thinking implmenting it by recursive reflection that would generate a code (I don't want to use refelction due performance).
Did anyone already implmented it ?
Thanks,
|
|
|
|
|
Hello,
I think implementing IClonable would help you!
Look at this article[^] from Amir Harel.
All the best,
Martin
|
|
|
|
|
I'm drawing Video on a Panel Object using AudioVideoPlayback Class. Now I'd like to put some text (or Image) on it. Any Ideas on how to do that???
Thanks...
|
|
|
|
|
Erhm, do you want to place the text in the video file, or do you just want to render the text over the video when playing ?
|
|
|
|
|
Hi.
I have some classes which I want to serialize to XML Documents.
If there is a field/property in an object of such type and it has a null value, when I serialize the object, the corresponding XML Node is omitted, so it doesn't appear at all in the output document.
Is there a way(I'm thinking maybe a Serialization attribute) to change this behavior so that in the generated XML document, the node appears with an empty value?
Thanks.
|
|
|
|
|