|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
To use ShellExecute or not?ShellExecute or not using it? I need to start IE when a link is clicked in my app. I want as little impact to my app as possible. What is the best method for this? In my case I have it working in a chat application. I use a RTB so that the links are detected. I click on the link and IE opens without problem 99% of the time. If a link is clicked at the exact moment text is being appended to the RTB, the app crashes with a threading error. So I guess I want to start the process and return from the call as fast as possible to see if I can alleviate the problem. Thanks for any help. *** Sent via Developersdex http://www.developersdex.com *** "Terry Olsen" <tolse***@hotmail.com> schrieb: What's the alternative? Not starting anything or using an alternate method > When starting a process, what is the difference between using > ShellExecute or not using it? to start the application? I recommend to use 'System.Diagnostics.Process.Start' instead of p/invoke with the 'ShellExecute' function. > I need to start IE when a link is clicked in my app. I want as little Are you adding the text to the textbox from another thread? Are you sure > impact to my app as possible. What is the best method for this? > > In my case I have it working in a chat application. I use a RTB so that > the links are detected. I click on the link and IE opens without > problem 99% of the time. > > If a link is clicked at the exact moment text is being appended to the > RTB, the app crashes with a threading error. you are using 'Control.{Invoke, BeginInvoke, InvokeRequired}' to access the control from the other thread instead of accessing it directly? -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/> Here's the code that I call from the SocketReceiveCallback routine...
Delegate Sub ToChatWindowDelegate(ByVal msg As String) Dim ChatDelegate As New ToChatWindowDelegate(AddressOf ToChatWindow) Dim ChatObject(0) As Object Private Sub ToChatWindow(ByVal msg As String) If msg = "" Then Exit Sub If txtChat.InvokeRequired Then ChatObject(0) = msg txtChat.Invoke(ChatDelegate, ChatObject) Else txtChat.AppendText(msg) End If End Sub Here's the code for the LinkClicked event Private Sub txtChat_LinkClicked(ByVal sender As Object, ByVal e As System.Windows.Forms.LinkClickedEventArgs) Handles txtChat.LinkClicked Dim pi As New ProcessStartInfo(e.LinkText) Process.Start(pi) End Sub What I'm wondering is what is the difference between using pi.UseShellExecute=True and pi.UseShellExecute=False? Which is better when all you want is to spawn an IE instance and get back as quickly as possible? Show quoteHide quote "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message news:%235lU5s8FGHA.1312@TK2MSFTNGP09.phx.gbl... > "Terry Olsen" <tolse***@hotmail.com> schrieb: >> When starting a process, what is the difference between using >> ShellExecute or not using it? > > What's the alternative? Not starting anything or using an alternate > method to start the application? I recommend to use > 'System.Diagnostics.Process.Start' instead of p/invoke with the > 'ShellExecute' function. > >> I need to start IE when a link is clicked in my app. I want as little >> impact to my app as possible. What is the best method for this? >> >> In my case I have it working in a chat application. I use a RTB so that >> the links are detected. I click on the link and IE opens without >> problem 99% of the time. >> >> If a link is clicked at the exact moment text is being appended to the >> RTB, the app crashes with a threading error. > > Are you adding the text to the textbox from another thread? Are you sure > you are using 'Control.{Invoke, BeginInvoke, InvokeRequired}' to access > the control from the other thread instead of accessing it directly? > > -- > M S Herfried K. Wagner > M V P <URL:http://dotnet.mvps.org/> > V B <URL:http://classicvb.org/petition/>
control arrays
howto make a console app start with window minimized Put standard output into file Spell checker How can you add a custom user control to a datagridview? modal dialog box Running app on Shared Drive Export from VB.NET 2003 to an Excel spreadsheet Pointer in a structure DataGridView... defaults to DataGridViewTextBoxColumn |
|||||||||||||||||||||||