InvokeRequired不从方法返回值

时间:2016-11-02 19:16:41

标签: vb.net

我使用InvokeRequired来保证线程安全,但是当涉及到我的方法时,如果我将值传递为true,它总是显示我的错误。为什么以及如何解决它?

Public Sub InitGrid(Optional myValue As Boolean = False)
            If Me.InvokeRequired Then
                Me.Invoke(New MethodInvoker(AddressOf InitGrid))
            Else
MsgBox(myValue.ToString()) //always false...
            End If
End Sub

1 个答案:

答案 0 :(得分:1)

您可以使用Action(of T)版本:

$headers = [
    'Api-Key'      => $this->apiKey,
];
$client = new Client([
    'headers' => $headers,
]);
$res = $client->put("{$this->baseUrl}/members/{$fields['vip_id']}", [
    'json' => $fields, // causes Guzzle to set content type to application/json
                       // and json_encode your $fields
]);