Answer Questions
Andy Britcliffe generic contraint for nullable objects
I have a generic method with a single parameter that must be nullable - a nullable type (int etc.) or a reference type. private static void SomeMethod<T>(T value) where T : Nullable Doing a search brought up this: http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=60915&SiteID=1 which mentions using INullableValue, but this seems to have been removed now. Is this possible As James pointed out, I also need to accept reference types. Is this possible There is no single constraint that does this, but you can easily achieve the same effect like so: private static void SomeMethod<T>(T value) where T : struct { ... } This will ensure th ...Show All
satsrinivasan CD-ROM opening and closing with two buttons
Hey all.First I will say that I am totally beginner in visual C# 2005 so I need very big help with one thing.I am trying to make when I click "button1" the cd-rom door opens and when I click "button2" the cd-rom door closes.I really need a big help in this!I tryed everything but there are always errors.So if anyone can help me with this,tell me everything in details if it's not a problem. THANKS! one way would be to use the WMP control, embed it into your application then use that to eject/insert the CD drives on the drive specified - but this is overkill just for doing what you like. I believe Win32/API calls are required for what you want to do, as stated, .NET does not have a direct function/class to ...Show All
smoon IDbConnection and get data in a dataset
Hello Everyone, I'm using IDbConnection to connect to database and that works perfectly fine.... I can do something like this as well...and this is good too.... IDbCommand command = conn.CreateCommand(); command.CommandText = "Select id, description from lot"; IDataReader dr = command.ExecuteReader(); while (dr.Read()) { string some = dr[1].ToString(); } The problem I'm facing is how to return it in dataset, as I directly want to bind my controls....or somebody can suggest a better way to do it... Thanks, Harsimrat Don't know what is the problem, by the way i don't have enough info. When you ask different question please create a new one with proble ...Show All
Manubhaskar Timer Question
I have a form with 2 buttons on it. Click on each button will launch their own methods. Let's say they are: button1_click button2 _click Now I want to add a timer to my form, and at specified intervals I would like the timer to launch each method, but I would like it to be as if I had clicked the button at that time. The reason is that I use a backgroundWorker, and I need my progressBar to still be able to update. Thanks for any help, Russ Hi Russ, if you want to trigger the buttons' click event from code, try invoking their PerformClick() method: private void timer_Tick( object sender, EventArgs e) { button1.PerformClick(); button2.PerformCli ...Show All
tonn tabpage disable
Hello everyone here is the deal: i have a tabcontrol which contains three tabpages,and i want to disable one of them,how can i do it,like i want to disable tabcontrol1.tabpage1,but it does not have this propertity,i just can disable the tabcontrol.how can i suceedd hi, i have asked the same question about the tabcontrol and its tabpages, i was told its not good thing to do here its the thread http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=234530&SiteID=1 hope this helps Public Class TabControlEx Inherits System.Windows.Forms.TabControl Private Const WM_LBUTTONDOWN As Integer = &H201 Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message) If ...Show All
W. Barbosa Aplication update automatically
Can anyone give me an idea and a sample function to check if there is a new version avaiable from a .exe and if there is, download and restart the application with the new version Thanks... PS: If someone has a demo project already done I would appreciate.. You have to use an 3rd party component/framework or have to write your own. Here is a list of resources: Writing a self-updating application in C# Using Updater Block .NET Application Updater Component Deploy and Update Your Smart Client Projects Using a Central Server If you're using VS2005 and ClickOnce deployment is an option to deploy your application, take a look at ApplicationDeployment class. Andrej ...Show All
Jim Perry What time format?
I got this string (14 bytes) as an output from a demo C# code I am trying to incorporate into my app. DateTime=12102006222639 It is 10/12/2006 but the rest of the string represents time. Is it possible to figure out by just looking at it or applying an operator the exact time represented by the rest of the string (6 bytes: 222639) Reading it so far did not make much sense to me. The presumed time is constrained by day time hours between 9:30 AM and 4:00 PM EST. Thanks. Alex, It might be a UTC timestamp. EST is UTC - 5... actually New York is still in EDT, which is UTC - 4, so your time would become something like 6:26PM. And even though I'm not an expert, I think the trading continues up to 6:30PM in the after hour sess ...Show All
Tdotsoulja BackgroundWorker design problem?
Can anyone comment on two apparent problems I've noticed with the "BackgroundWorker" class (e.g., the design pattern itself). The canonical examples always show a demonstration of a "Cancel" button handler invoking "BackgroundWorker.CancelAsync()" but two possible problems then arise: 1) What happens if the "Cancel" button handler is running around the same time that the worker thread is exiting. In this case, the worker thread may exit in which case the "RunWorkerCompleted()" handler will be invoked as soon as the "Cancel" handler returns. The "RunWorkerCompletedEventArgs" argument passed to "RunWorkerCompleted()" will then indicate that the thread exited eith ...Show All
ArcPadNewbie help with arrays
I have an application where I have two arrays such as: string [] array1 = { "one" , "two" , "three" , "four" }; string [] array2 = { "two" , "four" , "six" }; I am hoping that C# offers an easy way to compare the two arrays and return an array of those elements that are different (in this case, I would have a three-element array containing the strings "one", "three" and "six"). In PHP, it's as simple as (I may have the function name wrong, but you get the idea) differentArray = array_diff(array1, array2); I don't want to code all of the logic myself and it seems like a basic and useful enough function to be part ...Show All
Ajeeth Kumar open/close oledb connection
I connect and query my access database and populate my datagridview using the code below. My question is if I have to explicitly open or close the connection, please can you show me how & where... DataSet ds = new DataSet(); OleDbDataAdapter da = new OleDbDataAdapter(); OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Application.StartupPath + @"\MyDb.mdb;User Id=admin;Password=;"); string strSQL = "SELECT * FROM Log"; OleDbCommand cmd = new OleDbCommand(strSQL, con); da.SelectCommand = cmd; da.Fill(ds); this.dataGridView1.DataSource = ds.Tables[0]; Thanks Well the answer to that one seems to be: Stick the function call in the backgr ...Show All
Rotte02 how to overload a native function
Is it possible to overload a function from VS2005 IDE If so, I want to overload graphics.drawline() which signature in CF is drawline(pen, int x1, int y1, int x2, int y2). I want to change it to drawline (pen, point A, point B). Any help No, you cannot modify this class in any way. You have to write some sort of a wrapper/helper class. For instance: public static class ExtendedGraphics { void DrawLine (Graphics graphics, Pen pen, Point start, Point end) { //Implementaion using the available overloads... } } Thank you, it makes more sense now. ...Show All
Bagles1 How to cancel socket operations
I have an application that acts as an IPC mechanism between two systems running at different sites. There are multiple sockets being used with two threads per socket to handle sending and receiving. When a glitch occurs, the socket in error is closed and a new connection is opened. Now, I have a problem in that the next socket opened may get the same handle as the previous. That creates all sorts of confusion between the old threads, which should be exiting, and the new threads that think they have exclusive use of the socket. To get around this issue, I'm now performing a shutdown on the old socket and placing it on a stack for later clean-up. That ensures that the new socket(s) get unique handles. One issue though, is that the old thr ...Show All
Learning VB timing and "scheduling"
i have to write an application to do some stuff, firstly i need it to be "always on" and i need to be able to have "schedules" in the application, every 20 minutes, once or twice a day at certain time etc.... i guess that using a windows service and utilising the system.threading.timer class would be the best way to go about this... are there any other, maybe better, ideas about how to tackle this You know Windows already provides a service that does exactly this Is there any reason you can't use the windows scheduler service instead of writing your own service this is the class that will select the schedule and implement the threaded tim ...Show All
smilemax Localization in Console Apps
Is it possible to apply localization to Console applications If so, please let me know how to do it. Thanx, Purusothaman.R ...Show All
Donaghy What happens when app exits and BG Thread is working on db
Hi all, what would happen if my application exits and there is still a background thread running that is working (doing 100's of INSERTS and UPDATES) on the database from which the connection to the database was established in the application (Which is now exited). Would the queries fail to execute from the point the application exits By default it will terminate immediatly and application will be closed. That's why you have BG and FG Threads. BG will terminate immediatly and app will be closed. FG will keep the app alive until the last FG is active except the main app thread. You should be carefull especially when working with databases and BG threads. You should explicitly wait for BG to finish using some timeout, calling Thread. ...Show All
