Interesting. I have no idea who said it, but "Necessity is the mother of invention." During the overall discussion, I notice that liking or disliking a language feature seems a function of one particular coding habits. For example, personally, I have several "I don't like that, so I am not using it" code habit. Here's a quick list: - I don't like friend in C++. I am not comfortable with its use because 9 times out of 10 it is being used by a developer who is being lazy in their design and is not willing to put the effort in to refactor the design. - I don't like internal in C#, for a similar reason, although at least the scope of the keyword is clearly restricted to the assembly and namespace. Mind you, I have written some class-factories which use an internal specifier on the constructors. (Yup, I'm a hypocrite! ;) ) I don't know if I will like partial methods or not. I am concerned with the implication that a method exists, but gets compiled out completely simply because it does not get defined beyond the prototype. Of course, having said that ASSERT is a very useful tool in C++. Of course, what I really miss in C# from C++ is the ability to defined a template class. I realize I can write Reflector/Emit code to generate these things, but that pushes the template work back to me. In C++ I made heavy use of the templates in order to implement some general boiler plate. Every time I have a typed Collection in C#, or managed a COM pointer, I have desperately wished for the template class capabilities. j.
jchesney
Posts
-
Evolution of C# -
Threading.Monitor.Exit(x) throws ArgumentException... any ideas why?Hi All! I have simple application running under Windows CE 4.2, using compact framework 1.0 SP3. There are two timers (threads) operating in the program which read/manipulate a common variable of type integer. To prevent critical section collisions I am using the Threading.Monitor.Enter / Exit methods to acquire and release a lock on the variable in question. The Enter method call works. The Exit method call throws an exception, and I don't know why. Here is a sample chunk of code.
Public Class FormMain Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) MyBase.Dispose(disposing) End Sub 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents inputTimer As System.Windows.Forms.Timer Friend WithEvents outputTimer As System.Windows.Forms.Timer Private Sub InitializeComponent() Me.inputTimer = New System.Windows.Forms.Timer Me.outputTimer = New System.Windows.Forms.Timer ' 'inputTimer ' Me.inputTimer.Enabled = True ' 'outputTimer ' Me.outputTimer.Enabled = True Me.outputTimer.Interval = 500 Me.Text = "Threads" End Sub Public Shared Sub Main() Application.Run(New FormMain) End Sub #End Region Private _inputs As Integer = 0 Private Sub inputTimer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles inputTimer.Tick Try Threading.Monitor.Enter(_inputs) _inputs += 1 Threading.Monitor.Exit(_inputs) Catch ex As Exception MsgBox(ex.Message) End Try End Sub Private Sub outputTimer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles outputTimer.Tick Try Threading.Monitor.Enter(_inputs) _inputs = 0 Threading.Monitor.Exit(_inputs) Catch ex As Exception MsgBox(ex.Message)
-
Personal Firewall Leak TestsI hear your pain! Felt it too! My firewall is constantly complaining that my app has changed. It would be useful to have a firewall designed for developers, which not only did the work of a normal firewall but also integrated with the development environment / source control to detect when you were compiling a project. That way you could specify an .exe as being "Under Development" and therefore ignore the .exe. Once the project was checked in, the firewall could then remove the "Under Development" flag, and resume normal firewall activities. Thoughts? j. "...to him who is able to do exceedingly abundantly above all that we ask or think, according to the power that works in us, to him be glory..."