|
A task which uses BeginInvoke is supposed to use EndInvoke to clean up; fire-and-forget semantics are explicitly discouraged. If one wants to launch a fire-and-forget thread, what disadvantage is there to simply saying:
Dim Th as New Thread(me.ThreadProc)
Th.IsBackground = True
Th.Start
as a means of running ThreadProc asynchronously? If Th exits, is some cleanup required, or will it get garbage-collected if no reference to it exists?
|
|
|
|
|
This code is fine for running an async operation. .NET takes care of all the complicated stuff, so you don't need to do any explicit cleanup, the thread will finish and cleanup automatically when ThreadProc method exits.
The only thing to look out for is marshalling to the main thread if you want to update / read any ui elements, e.g. setting .Text property on a label control from within ThreadProc. In this case, you must do something like:
Private Delegate Sub UpdateLabelTextDelegate(ByVal value As String)
Private Sub UpdateLabelText(ByVal value As String)
If Label1.InvokeRequired Then
Label1.BeginInvoke(New UpdateLabelTextDelegate(AddressOf UpdateLabelText), New Object() {value})
Else
Label1.Text = value
End If
End Sub
Also, the following can be used as a shortcut to read the label text (only in VS2008 though):
Dim value As String = If(Label1.InvokeRequired, CStr(Label1.Invoke(Function() Label1.Text)), Label1.Text)
Rob
"An eye for an eye only ends up making the whole world blind"
|
|
|
|
|
Won't "BeginInvoke" create a leak if there's no "EndInvoke"?
|
|
|
|
|
I've been doing it this way for years! maybe i've been getting it wrong! will re-read msdn later...
"An eye for an eye only ends up making the whole world blind"
|
|
|
|
|
I have a .Net DLL. Can I use it from a Java program (assuming .Net is installed of course).
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
|
Yeah, and if you wanted to make beer you could mix a frog and an egg in blender.
led mike
|
|
|
|
|
led mike wrote: Yeah, and if you wanted to make beer you could mix a frog and an egg in blender.
I think I drank some of that - well, it explains the way I felt after I drank 11 or 12 of them.
|
|
|
|
|
Pete O'Hanlon wrote: I think I drank some of that
LMAO Well it's FRIDAY so I'm off for the real Have a great weekend!
led mike
|
|
|
|
|
led mike wrote: Well it's FRIDAY so I'm off for the real Have a great weekend!
You too mate. Be good. If you can't be good, be legal. If you can't be legal, what the hell - enjoy yourself.
|
|
|
|
|
Hi there!
I would like to know if it's possible, and if so, how can I add a reference to a library programatically in the .net framework.
The idea is to have somethin like we had with the CreateObject("library_name") in the VB6 days.
Any help is welcome!
Thanks in advance for your time.
António
|
|
|
|
|
|
There is a complete library in .Net called Reflection that allows you to query a type or create an instance without referencing the assembly on compile.
I would suggest you to go through the Reflection namespace and esp Assembly class. (http://msdn.microsoft.com/en-us/library/system.reflection.aspx[^]
Tariq A Karim
http://moplah.blogspot.com/
|
|
|
|
|
I have been tasked with researching third party object-relational mapping and RAD frameworks for .NET
Our organization is just starting a long term migration from VFP to C# / .NET and wants to kick start this process by employing a third - party ORM framework.
I have not used any third party frameworks for ORM in .NET yet and don't want to get painted into a corner at this early stage.
One of the frameworks we are reviewing is called Mere Mortals.NET by Oak Leaf Enterprises Solution Design.
I have also heard of another product called IronBlade Dev Force.
Anybody had experience with these products or third-party ORM frameworks in general.
Tim Holgerson
|
|
|
|
|
I know Pete has already mentioned about cross-posting, so I'm just adding a pointer to the other message here. That way, if someone else goes to answer or look for an answer they know where to go.
Original message here[^].
Scott Dorman Microsoft® MVP - Visual C# | MCPD
President - Tampa Bay IASA
Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai
[ Forum Guidelines][ Articles][ Blog]
|
|
|
|
|
Im trying to make a custom user control (web control or ascx control) with my own custom elements but I can't get it to work. It is easy to add custom attributes (like DataTableName in example below) to a custom contol. The following code will demonstrate what I mean by custom element.
<custCtrl:custTable ID="MyCustTable" runat="server" DataTableName="Groups">
<custCtrl:Columns>
<custCtrl:custColumn ColumnName="Column1"><custCtrl:custColumn>
<custCtrl:custColumn ColumnName="Column2"><custCtrl:custColumn>
.
.
.
<custCtrl:custColumn ColumnName="Columnx><custCtrl:custColumn>
</custCtrl:Columns>
</custCtrl:custTable>
I've searched for articles like this but I couldn't find any. any help will be appreciated.
Thanks
|
|
|
|
|
|
hi all,
we have developed application on dotnetframework2 on wondows xp OS.
we have set the form size to maximum on load.
but we are recicving complain stated as
The forms are not fully displayed when the screen resolution is less that 1024x768. It is not possible to navigate to fields which are not displayed, there are no scroll bars to see the hidden screen area.
how can we resolve this issue. Any help on this please.
|
|
|
|
|
Hi,
Do you set the hard code size? I mean how do you set the maximum size?
Cheers
Ashik
|
|
|
|
|
well i do that by setting the Windowstate property to Maximized during the design time
|
|
|
|
|
Hi,
Take a look at this article on msdn about automatic scaling of Windows forms.
http://msdn.microsoft.com/en-us/library/ms229605(VS.80).aspx[^]
Also I'm not sure if you have understood your customer's problem. Switch one of your monitors to 800x600 resolution, run your app and I think all will become clear.
AlanN
|
|
|
|
|
You can use a combination of tablelayout, flowlayout, form and controls' dock property to make all the controls scale nicely (thought not perfectly).
|
|
|
|
|
Hello
I am using multicast delegate as follows, but the effect in the server is undesirable:
Thing.OnEvent1 += new IThingEvents_OnEvent1EventHandler(OnEvent1);
Thing.OnEvent2 += new IThingEvents_OnEvent2EventHandler(OnEvent2);
Thing.OnEvent3 += new IThingEvents_OnEvent3EventHandler(OnEvent3);
The problem is that the (C++ COM) server it thinks it has all the connections for each event.
So in the below example it trys to send the event 3 times. Apart from the unecessary processing, I am worried it is making the inter-process call each time (the incorrect calls are being thrown away on the client side somewhere).
HRESULT Fire_OnOrderCancel(lots of params)
{
HRESULT hr = S_OK;
T * pThis = static_cast(this);
int cConnections = m_vec.GetSize();
for (int iConnection = 0; iConnection < cConnections; iConnection++)
{
pThis->Lock();
CComPtr punkConnection = m_vec.GetAt(iConnection);
pThis->Unlock();
IDispatch * pConnection = static_cast(punkConnection.p);
if (pConnection)
{
CComVariant avarParams[20];
//set avarParams
CComVariant varResult;
DISPPARAMS params = { avarParams, NULL, 9, 0 };
hr = pConnection->Invoke(1, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, ¶ms, &varResult, NULL, NULL);
}
}
return hr;
}
What c#/.net thing do I need to use to get the desired behaviour, namely events to be fired once and the c# client to do the correct delegation?
Many Thanks
deds
|
|
|
|
|
Hi
I need to take the user session ID number (maybe is called session token or SID) in my windows VB.Net application, it is a unique number per session, same user different sessions should have different numbers. I tried a lot of ways (almost everything from win32) without success....
|
|
|
|
|
This sounds like what you need:
Process.GetCurrentProcess.SessionId
Good luck!
|
|
|
|