ALGUEM ME AJUDA COM ESSE ERRO?

JAISONKLEMER 05/04/2014 16:26:15
#436930
Ta dando esse erro nessa class. Alguém pode me ajuda??
CLEVERTON 05/04/2014 19:12:53
#436938
Cara, posta o código no tópico, pois não consigo baixar, o site deve está com algum problema.
e quando for criar um tópico, coloca um titulo sugestivo para que as pessoas tenham interesse e possam lhe ajudar adequadamente.

dá uma olhada nas regras de conduta
JAISONKLEMER 06/04/2014 14:02:19
#436950
Citação:

:
Cara, posta o código no tópico, pois não consigo baixar, o site deve está com algum problema.
e quando for criar um tópico, coloca um titulo sugestivo para que as pessoas tenham interesse e possam lhe ajudar adequadamente.

dá uma olhada nas regras de conduta


[quote]:

Ok, me desculpe pelos erros.

Aqui está o código:
   

Imports System
Imports System.Linq
Imports System.Drawing
Imports Awesomium.Core
Imports System.Windows.Forms
Imports Awesomium.Windows.Forms

Namespace TabbedFormsSample
Friend NotInheritable Class Program

Private Sub New()
End Sub

[ô][ô][ô] <summary>
[ô][ô][ô] The main entry point for the application.
[ô][ô][ô] </summary>
<STAThread> _
Shared Sub Main(ByVal args() As String)
[ô] Force single instance application.
SingleInstance.Make(AddressOf SecondInstance)

Application.EnableVisualStyles()
Application.SetCompatibleTextRenderingDefault(False)

[ô] Set some initialization settings.
Dim webConfig As New WebConfig() With {.HomeURL = New Uri([Ô]http://www.google.com[Ô]), .LogLevel = LogLevel.Verbose}

[ô] Lazy initialization of the core.
WebCore.Initialize(webConfig)

Application.Run(New MainForm())
End Sub

Private Shared Sub SecondInstance(ByVal obj As Object)
Dim forms = Application.OpenForms.OfType(Of MainForm)()

If forms.Count() > 0 Then
forms.First().BeginInvoke(CType(RestoreMainForm, Action(Of MainForm)), forms.First())
End If
End Sub
Private Shared Sub RestoreMainForm(ByVal mainForm As MainForm)
If mainForm.WindowState = FormWindowState.Minimized Then
mainForm.WindowState = FormWindowState.Normal
End If

mainForm.Focus()
mainForm.OpenTab()
End Sub

[ô] Common handler of all ShowCreatedWebView events.
Friend Shared Sub OnShowNewView(ByVal sender As Object, ByVal e As ShowCreatedWebViewEventArgs)
Dim view As IWebView = TryCast(sender, IWebView)

If view Is Nothing Then
Return
End If

If Not view.IsLive Then
Return
End If

Dim mainForm As MainForm = Application.OpenForms.OfType(Of MainForm)().FirstOrDefault()

If mainForm Is Nothing Then
Return
End If

[ô] Treat popups differently. If IsPopup is true, the event is always
[ô] the result of [ô]window.open[ô] (IsWindowOpen is also true, so no need to check it).
[ô] Our application does not recognize user defined, non-standard specs.
[ô] Therefore child views opened with non-standard specs, will not be presented as
[ô] popups but as regular new windows (still wrapping the child view however -- se below).
If e.IsPopup AndAlso (Not e.IsUserSpecsOnly) Then
[ô] JSWindowOpenSpecs.InitialPosition indicates screen coordinates.
Dim screenRect As Rectangle = e.Specs.InitialPosition.ToRectangle()

[ô] Set the created native view as the underlying view of the
[ô] WebControl. This will maintain the relationship between
[ô] the parent view and the child, usually required when the new view
[ô] is the result of [ô]window.open[ô] (JS can access the parent window through
[ô] [ô]window.opener[ô]; the parent window can manipulate the child through the [ô]window[ô]
[ô] object returned from the [ô]window.open[ô] call).
Dim newWindow As New WebDocument(e.NewViewInstance) With {.ShowInTaskbar = False, .ClientSize = If(screenRect.Size <> Size.Empty, screenRect.Size, New Size(640, 480))}

[ô] If the caller has not indicated a valid size for the new popup window,
[ô] let it be opened with the default size specified at design time.
If (screenRect.Width > 0) AndAlso (screenRect.Height > 0) Then
[ô] Assign the indicated size.
newWindow.Width = screenRect.Width
newWindow.Height = screenRect.Height
End If

[ô] Show the window.
newWindow.Show()

[ô] If the caller has not indicated a valid position for the new popup window,
[ô] let it be opened in the default position specified at design time.
If screenRect.Location <> Point.Empty Then
[ô] Move it to the specified coordinates.
newWindow.DesktopLocation = screenRect.Location
End If
ElseIf e.IsWindowOpen OrElse e.IsPost Then
[ô] No specs or only non-standard specs were specified, but the event is still
[ô] the result of [ô]window.open[ô] or of an HTML form with tagret=[Ô]_blank[Ô] and method=[Ô]post[Ô].
[ô] We will open a normal window but we will still wrap the new native child view,
[ô] maintaining its relationship with the parent window.
Dim doc As New WebDocument(e.NewViewInstance)
mainForm.OpenTab(doc)
Else
[ô] The event is not the result of [ô]window.open[ô] or of an HTML form with tagret=[Ô]_blank[Ô]
[ô] and method=[Ô]post[Ô]., therefore it[ô]s most probably the result of a link with target=[ô]_blank[ô].
[ô] We will not be wrapping the created view; we let the WebControl hosted in ChildWindow
[ô] create its own underlying view. Setting Cancel to true tells the core to destroy the
[ô] created child view.
[ô]
[ô] Why don[ô]t we always wrap the native view passed to ShowCreatedWebView?
[ô]
[ô] - In order to maintain the relationship with their parent view,
[ô] child views execute and render under the same process (awesomium_process)
[ô] as their parent view. If for any reason this child process crashes,
[ô] all views related to it will be affected. When maintaining a parent-child
[ô] relationship is not important, we prefer taking advantage of the isolated process
[ô] architecture of Awesomium and let each view be rendered in a separate process.
e.Cancel = True
[ô] Note that we only explicitly navigate to the target URL, when a new view is
[ô] about to be created, not when we wrap the created child view. This is because
[ô] navigation to the target URL (if any), is already queued on created child views.
[ô] We must not interrupt this navigation as we would still be breaking the parent-child
[ô] relationship.
Dim doc As New WebDocument(e.TargetURL)
mainForm.OpenTab(doc)
End If
End Sub
End Class
End Namespace



O erro está aqui :
   Private Shared Sub SecondInstance(ByVal obj As Object)
Dim forms = Application.OpenForms.OfType(Of MainForm)()

If forms.Count() > 0 Then
forms.First().BeginInvoke(CType(RestoreMainForm, Action(Of MainForm)), forms.First())
End If
End Sub
Private Shared Sub RestoreMainForm(ByVal mainForm As MainForm)
If mainForm.WindowState = FormWindowState.Minimized Then
mainForm.WindowState = FormWindowState.Normal
End If

JABA 10/04/2014 12:27:29
#437142
O erro acontece porque você não passou o parametro do metodo RestoreMainForm via BeginInvoke.

Dá uma olhadinha aqui:

http://msdn.microsoft.com/pt-br/library/a06c0dc2(v=vs.110).aspx
KERPLUNK 10/04/2014 13:48:29
#437145
1 - Você está achando que ter um form controlado por uma thread vai ajudar em alguma coisa
2 - Você não tem a menor idéia de como threads funcionam, simplesmente copiou e colou código tirado de algum lugar e nem mesmo tirou os comentários
3 - Você não sabe ver erros. O que você mostrou, diz a causa e o lugar(linha) onde o erro ocorre

O que você deve fazer:
1 - Estudar para que servem e como são usadas threads
2 - Fazendo o que indico acima, você vai entender que o que está fazendo não se deve fazer
3 - Aprender a ler erros, a causa e o local estão quase sempre indicados nele
4 - Aprender a depurar código. Assim, você vai ver exatamente onde você está errando
5 - Aprender sobre conceitos de programação, assim, você nem se importará mais com código
Faça seu login para responder