Today I had to tweak one of our internal tools written in VB.NET, and
wish so much that there be macros... but I knew there ain't.
Here is the problem: on .NET if you want to update a GUI control from
the non-main thread, you have to make a delegate, prepare an invocation,
put the parameters and call it. For example:
Public Sub UpdateConnectionStatus(ByVal connectionOK As Boolean)
If (connectionOK) Then
form.ConnectionLost.Hide()
form.ConnectionOK.Show()
Else
form.ConnectionOK.Hide()
form.ConnectionLost.Show()
End If
End Sub
Basically this simple sub would be called with True or False, whether
the image displaying ConnectionLost would be shown, or the ConnectionOK.
anyhow, calling this code from the non-main thread does not work. So
here is some "awesomeness" you have to do to achieve this:
Public Delegate Sub UpdateConnectionStatusDelegate(ByVal
connectionOK As Boolean)
Public Sub UpdateConnectionStatus(ByVal connectionOK As Boolean)
If (form.InvokeRequired()) Then
form.Invoke(New UpdateConnectionStatusDelegate(AddressOf
UpdateConnectionStatus), New Object() {connectionOK})
ElseIf (connectionOK) Then
form.ConnectionLost.Hide()
form.ConnectionOK.Show()
Else
form.ConnectionOK.Hide()
form.ConnectionLost.Show()
End If
End Sub
But the question is why? Why in first place Microsoft invented such
dumb way of doing the things, and why there wasn't any band-aid
provided? That's not the only place, it's all over.
And if VB.NET just had macroses - it would've been way easier.
Choice of Language Do Matter. I don't care whether it's .NET or any
other runtime, it's about the language. And VB.NET sucks big time!
Before asking me why VB.NET was chosen for that particular application,
is simply because VB is thought of the easiest language for a scripter,
designer, any non-heavy programmer type, but creative.
On Sep 26, 7:30 pm, "Dimiter \"malkia\" Stanev" <······@gmail.com>
wrote:
> Today I had to tweak one of our internal tools written in VB.NET, and
> wish so much that there be macros... but I knew there ain't.
>
> Here is the problem: on .NET if you want to update a GUI control from
> the non-main thread, you have to make a delegate, prepare an invocation,
> put the parameters and call it. For example:
>
> Public Sub UpdateConnectionStatus(ByVal connectionOK As Boolean)
> If (connectionOK) Then
> form.ConnectionLost.Hide()
> form.ConnectionOK.Show()
> Else
> form.ConnectionOK.Hide()
> form.ConnectionLost.Show()
> End If
> End Sub
>
> Basically this simple sub would be called with True or False, whether
> the image displaying ConnectionLost would be shown, or the ConnectionOK.
>
> anyhow, calling this code from the non-main thread does not work. So
> here is some "awesomeness" you have to do to achieve this:
>
> Public Delegate Sub UpdateConnectionStatusDelegate(ByVal
> connectionOK As Boolean)
>
> Public Sub UpdateConnectionStatus(ByVal connectionOK As Boolean)
> If (form.InvokeRequired()) Then
> form.Invoke(New UpdateConnectionStatusDelegate(AddressOf
> UpdateConnectionStatus), New Object() {connectionOK})
> ElseIf (connectionOK) Then
> form.ConnectionLost.Hide()
> form.ConnectionOK.Show()
> Else
> form.ConnectionOK.Hide()
> form.ConnectionLost.Show()
> End If
> End Sub
>
> But the question is why? Why in first place Microsoft invented such
> dumb way of doing the things, and why there wasn't any band-aid
> provided? That's not the only place, it's all over.
>
> And if VB.NET just had macroses - it would've been way easier.
>
> Choice of Language Do Matter. I don't care whether it's .NET or any
> other runtime, it's about the language. And VB.NET sucks big time!
>
> Before asking me why VB.NET was chosen for that particular application,
> is simply because VB is thought of the easiest language for a scripter,
> designer, any non-heavy programmer type, but creative.
Why are you posting this on c.l.l instead of some VB.NET list?
(message (Hello 'Dimiter)
(you :wrote :on '(Wed, 26 Sep 2007 17:30:29 -0700))
(
DmS> But the question is why? Why in first place Microsoft invented such
DmS> dumb way of doing the things, and why there wasn't any band-aid
DmS> provided? That's not the only place, it's all over.
sometimes it seems that everything VB-related is made specially dumb and
idiotic.
do you know, for example, that in VBA editor you can't use mouse wheel to
scroll?
in any other normal Windows app, in Excel itself (which launches this VBA
editor), even in simpliest notepad you can do that.
but in VBA editor it's disabled (or just not implemented). and certainly it
annoys..
so is the VB language itself -- for absolutely no reasons it have features
that make programming better disabled.
DmS> And if VB.NET just had macroses - it would've been way easier.
with macros VB programs would be absolute freaking weirdness.
they'd better implement properly other language features..
e.g. if you'd have lambda (first-class functions) you won't really need
macros is 99% places.
)
(With-best-regards '(Alex Mizrahi) :aka 'killer_storm)
"Hanging In The Balance Of Deceit And Blasphemy")
Dimiter "malkia" Stanev wrote:
> Today I had to tweak one of our internal tools written in VB.NET, and
> wish so much that there be macros... but I knew there ain't.
>
> Here is the problem: on .NET if you want to update a GUI control from
> the non-main thread, you have to make a delegate, prepare an invocation,
> put the parameters and call it.
If you use F# then you just pass a function to the Invoke method:
form.Invoke(fun () -> ...)
This is also statically type checked, which Lisp macros are not.
> Choice of Language Do Matter. I don't care whether it's .NET or any
> other runtime, it's about the language. And VB.NET sucks big time!
Of course, but .NET is all about language interoperability, so you should be
able to develop new code in nicer languages like F# with minimal fuss.
--
Dr Jon D Harrop, Flying Frog Consultancy
http://www.ffconsultancy.com/products/?u
Jon Harrop wrote:
> Of course, but .NET is all about language interoperability, so you should be
> able to develop new code in nicer languages like F# with minimal fuss.
What's the difference between VB and F#? I thought they were both the
same. In any case, they're both obsolete.