|
What do you mean by "it doesn't work"? Does it compile? throw an exception? Return an unexpected result? ...
|
|
|
|
|
Sorry for leaving that out...it says I'm still in violation of cross-threading. The invoke should of got me on the forms thread but it is not working.
'Never argue with an idiot; they'll drag you down to their level and beat you with experience.' ~ anonymous
'Life's real failure is when you do not realize how close you were to success when you gave up.' ~ anonymous
|
|
|
|
|
nlarson11 wrote: The invoke should of got me on the forms thread
The Invoke does execute in the UI thread, but that is totally pointless as all you are doing is returning a reference to the form. The reference doesn't get any different from being returned from another thread, and when you use the reference, you are still using it from your thread.
It's whatever you do with the form that you need to call using Invoke.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Hi Nathan,
Following is a demo of Funtion Delegates in VB.Net
BEGIN CODE
Imports System
Public Class MainClass
Dim emp As New Employee("First Name", "Last Name")
Private Delegate Function NumEmployeesDelegate() As Integer
Shared Sub Main(ByVal args As String())
Dim show_num As NumEmployeesDelegate
show_num = AddressOf Employee.GetNumEmployees
Console.WriteLine(show_num().ToString)
End Sub
End Class
Public Class Employee
Private m_FirstName As String
Private m_LastName As String
Private Shared m_NumEmployees As Integer = 0
Public Shared Function GetNumEmployees() As Integer
Return m_NumEmployees
End Function
Public Sub New(ByVal first_name As String, ByVal last_name As String)
m_FirstName = first_name
m_LastName = last_name
m_NumEmployees += 1
End Sub
Public Overrides Function ToString() As String
Return m_FirstName & " " & m_LastName
End Function
Private disposedValue As Boolean = False ' To detect redundant calls
End Class
END CODE
Hope thhis helps
Regards,
John Adams
ComponentOne LLC
|
|
|
|
|
Hey John,
Thank you. I need an example that deals with a Forms UI thread where I have to test if an invoke is required and invoke to get on that form's thread. I know i can do this with a Sub Delegate but the Function Delegate I can't?
'Never argue with an idiot; they'll drag you down to their level and beat you with experience.' ~ anonymous
'Life's real failure is when you do not realize how close you were to success when you gave up.' ~ anonymous
|
|
|
|
|
Is the error happening inside this function or after the function call when you use the value returned from it?
If it is the latter, than the problem is that the call to Invoke only makes GetOnFormsUIThread be on the main thread. The function that called it originally is still on a different thread and any access to the members of the form returned from the function will continue to throw an exception.
|
|
|
|
|
I'm trying to create a custom control with on it a label and textbox (for now)
I want to be able to set the properties of these controls at design time, but when I do this they keep being reverted back to there initial settings (at run time).
Any ideas on how to solve this?
|
|
|
|
|
a 'user control' will do what you want.
'Never argue with an idiot; they'll drag you down to their level and beat you with experience.' ~ anonymous
'Life's real failure is when you do not realize how close you were to success when you gave up.' ~ anonymous
|
|
|
|
|
not really
I have a 'user control' with on it a label and a textbox
I want to be able to set the properties off the label and textbox at design time (I can do this but when I run the test project the properties are reset to there original value's)
|
|
|
|
|
You'll have to write code to re-expose those properties yourself. You don't make the Label and TextBox controls public. You keep them private, then expose just the properties you want. For example, in your UserControl code, you can expose the Text Property of it's constituant Lable control like this:
Public Property LabelText() As String
Get
Return MyLabelControl.Text
End Get
Set(ByVal value As String)
MyLabelControl.Text = value
End Set
End Property
|
|
|
|
|
So there is no way to expose them all (except doing making a property myself for all of them)
Ok thank you for the help, I guess I'm off to writing properties now
|
|
|
|
|
I have a VB.Net COM dll that I created and installed (using regasm) on a server. On this server is an application that calls different code modules based on events. One of those code modules calls the com dll which fires off and does a few things. If this process is kicked off from the server, everything works just fine. However, when the application is run from a workstation, the COM call fails. The workstation calls the code modules that reside on the server, the same ones that the server uses.
So why would the call to the COM object work fine on the Server, but when called through a workstation, to the server, fails out?
The CreateObject statement that creates the com object does not fail, but when called through the workstation, the call to the COM method fails.
Here's an example:
foo = CreateObject("Obj.Class")
result = foo.callMethod
The CreateObject works fine, but the foo.callMethod fails when it is kicked off from a workstation.
Anyone run into something like this before?
|
|
|
|
|
if you have brought that object to the PC then everything it talks that it talked to on the server also needs to be on the PC (excluding http and sql server calls). It will not execute code on the server.
'Never argue with an idiot; they'll drag you down to their level and beat you with experience.' ~ anonymous
'Life's real failure is when you do not realize how close you were to success when you gave up.' ~ anonymous
|
|
|
|
|
Sorry, I may not have explained well enough. It's setup like this: The server hosts the main application. Workstations have a satellite application that calls the main one to do most of the processing. The code that calls the COM object resides on the server. So everytime the server's main application is called, it will fire off the COM object. If the code to fire that COM object is called from the server itself, then it runs fine. But, if the satellite application calls the main application on the server, then it errors out.
|
|
|
|
|
How can I call functions from a "normal" (just plain old C) DLL from my VB.NET program? Also, is it possible to get a list of functions that are exported by the DLL?
|
|
|
|
|
There's a good bit of sample code out there, like this article.[^]. As for listing the functions, I don't think you can, but I don't always know everything.
|
|
|
|
|
I'm teaching myself vb.net again after being out of school for a few years. My problem is probably simple although I don't know the correct terminology so it makes it hard to search for a solution. I am making a simple game with picture boxes. I created the variable YellowDrop which is a string. It concatenates a few things to create "Yellow6x1" for example. This is a picture box. I now need the command equivalent to yellow6x1.visible. I cannot just do yellowdrop.visible because visible is not a part of string. Can someone point me in the correct direction? Thank you.
If cbColor.Text = "Yellow" Then
For RowLoop = 6 To txtRow.Text Step -1
YellowDrop = ("Yellow" & (RowLoop) & "x" & (txtColumn.Text))
'****Here is where I need a command that would act like YellowDrop.visible****
Next
End If
modified on Friday, October 3, 2008 10:48 AM
|
|
|
|
|
I think i'm getting closer by making yellowdrop a picturebox... but not quite there.
Dim RowLoop As Integer
Dim YellowDrop As PictureBox
If cbColor.Text = "Yellow" Then
For RowLoop = 6 To txtRow.Text Step -1
YellowDrop.Name = ("Yellow" & (RowLoop) & "x" & (txtColumn.Text))
YellowDrop.Visible = True
Next
End If
modified on Friday, October 3, 2008 10:48 AM
modified on Friday, October 3, 2008 1:13 PM
|
|
|
|
|
You will need to use 'reflection' to accomplish what you want to do.
'Never argue with an idiot; they'll drag you down to their level and beat you with experience.' ~ anonymous
'Life's real failure is when you do not realize how close you were to success when you gave up.' ~ anonymous
|
|
|
|
|
The best bet would probably be to make an array of controls and then index into that array. Depending on your configuration it may make sense to have a two dimension array.
|
|
|
|
|
Hello,
My application consists of an EXE acting as a main menu. Each menu item opens an app that sits in 1-many dlls. Each application has the ability to communicate in one way or another via a object handler that I called the HUB. They all have shared memory as well as shared objects they can access to get things like security and user information, etc.
Problem #1)
All of these apps are started via the main thread and if one of the apps dies, it has the potential of killing everything on the thread. I have added appropriate onthreadexception and unhandled exception error handling but again...but depending on the error, recovery of the other apps may or not be consistent.
Problem #2)
Each one of these apps has the possibility of showing a dialog box (msgbox or one of my own). Because each app was started on the main thread...all the other apps are locked until that one app shutsdown the dialogbox because as you know the dialogbox blocks execution.
I would appreciate any design tips on how you get around these issues and how you handle a multiple application suite of software that communicates with each other. I'm open to redesigning if it takes that effort to straighten these two issues out...
Thank you
Nathan
'Never argue with an idiot; they'll drag you down to their level and beat you with experience.' ~ anonymous
'Life's real failure is when you do not realize how close you were to success when you gave up.' ~ anonymous
|
|
|
|
|
Are these truely "separate apps" or can you redesign it to fit into a Muli-Document Interface model ?
|
|
|
|
|
they are seperate apps sharing and reusing "global" components
mdi will not fix the 2 problems...all the apps must be functional at the same time...and putting them in an mdi will not meet user requirement...
'Never argue with an idiot; they'll drag you down to their level and beat you with experience.' ~ anonymous
'Life's real failure is when you do not realize how close you were to success when you gave up.' ~ anonymous
|
|
|
|
|
Hi all...
I want to know that how to define column size of datagridview.
By default all columns are of same size.I want to change size of columns so that at runtime it will display different fields of different size.
Thanks...
Gagan.
|
|
|
|
|
This has nothing whatsoever to do with database design.
Right click on your datagridview, select Edit Columns and adjust the Width property to what you need it to be.
Bob
Ashfield Consultants Ltd
|
|
|
|