invoke

Need help getting info across a UI thread and another thread in C#

ぃ、小莉子 提交于 2019-12-06 07:48:00
I have a server application that receives information over a network and processes it. The server is multi-threaded and handles multiple sockets at time, and threads are created without my control through BeginInvoke and EndInvoke style methods, which are chained by corresponding callback functions. I'm trying to create a form, in addition to the main GUI, that displays a ListBox item populated by items describing the currently connected sockets. So, what I'm basically trying to do is add an item to the ListBox using its Add() function, from the thread the appropriate callback function is

How to invoke a php file that is located outside public_html

我是研究僧i 提交于 2019-12-06 06:43:40
问题 Im creating a website and i am very OCD when it comes to security so i heard that if you store all of your .php files outside of your public_html folder and invoke them with another .php file that is inside your public_html folder then your risk of an attack is lower. Is this true, if so how would i do this. I read something about using .htaccess but I'm not sure if that was the correct way to do it. I though i could maybe use include but im not sure how include works with parameters. 回答1:

C# Catching Exception From Invoked Delegate on another Thread

扶醉桌前 提交于 2019-12-06 05:19:40
I have some code as follows. This is running on "Thread 2" WebBrowser browser = this.webBrowser browser.Invoke(new MethodInvoker(delegate { browser.Document.GetElementById("somebutton").InvokeMember("click"); })); Thread.Sleep(500); browser.Invoke(new MethodInvoker(delegate { browser.Document.GetElementById("username").SetAttribute("value", username); })); //folowed by several more similar statments Essentially I am Invoking some methods on a WebBrowser control created on a different thread, "Thread 1". If the element on the current page loaded in browser does not contain an element "somebtn"

Dynamically calling a dll and method with arguments

巧了我就是萌 提交于 2019-12-06 02:32:40
问题 Basically I'm trying to call a dll by name, instantiate an object, then call a method by name in that dll. I'm getting an "Exception has been thrown by the target of an invocation." during the Method.Invoke. I'm fairly sure my problem is with the typecasting of the arguments of the method. I was wondering if anyone had any input on this exception. Additionally, any suggestions on how to revise my approach are welcome. public void calldll(string dllName, string typeName, string methodName,

VB.NET Invoke cannot be called on a control until the window handle has been created, BUT the handle is created

妖精的绣舞 提交于 2019-12-06 01:54:33
This is my situation, there are 2 Classes and my main form Form1: Class1: has a method doSomethingAndCall(callback) which creates a new thread Class2: has dynamic created controls with a button that fires Class1.doSomethingAndCall(newCallback) in code it looks like this (it starts at Class2.Button_Click): Class Class1 public shared sub doSomethingAndCallAsync(state as object) Console.WriteLine(Form1.InvokeRequired) 'output: false Console.WriteLine(Form1.IsHandleCreated) 'output: false Form1.Invoke(state.callback) 'throws System.InvalidOperationException end sub public shared sub

VB.net, Invoke, delegates, and threading. Can't figure out how to use them across classes

自作多情 提交于 2019-12-05 21:13:51
Long story short, I'm having a hell of a time trying to figure out how to use invoke and/or delegates to update the userform from a separate class when using threading. I'm quite sure it's something silly and obvious to someone with more experience. I know a delegate is probably required, but all my efforts seem to only work when it's being called from main thread. I've been looking around the internet for half the day, and there's just something I'm not getting. Here's some pseudo-code as an example: This option works: Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object

Control.Invoke getting 'stuck' in hidden ShowDialog

醉酒当歌 提交于 2019-12-05 16:01:04
(I have a workaround for this problem, but it's not the first time I've been bitten, so I'm trying to understand exactly what's going on.) From my application, I ShowDialog a form. On the form is a button, which when clicked calls code on another (non-Gui) thread. The non-GUI thread sends back statuses ( Pushed then Released ) via a Control.Invoke When the form sees the Pushed , it invokes form.Hide() When the form sees the Released , it changes the appearance of the button. What happens is that sometimes, but not everytime, the non-Gui thread gets 'stuck' trying to send the Released . No

alternative for using slow DynamicInvoke on muticast delegate

浪子不回头ぞ 提交于 2019-12-05 14:39:14
I have the following piece of code in a base-class: public static void InvokeExternal(Delegate d, object param, object sender) { if (d != null) { //Check each invocation target foreach (Delegate dDelgate in d.GetInvocationList()) { if (dDelgate.Target != null && dDelgate.Target is System.ComponentModel.ISynchronizeInvoke && ((System.ComponentModel.ISynchronizeInvoke)(dDelgate.Target)).InvokeRequired) { //If target is ISynchronizeInvoke and Invoke is required, invoke via ISynchronizeInvoke ((System.ComponentModel.ISynchronizeInvoke)(dDelgate.Target)).Invoke(dDelgate, new object[] { sender,

VB.NET Two different approaches to generic cross-threaded operations; which is better?

老子叫甜甜 提交于 2019-12-05 11:08:03
VB.NET 2010, .NET 4 Hello, I recently read about using SynchronizationContext objects to control the execution thread for some code. I have been using a generic subroutine to handle (possibly) cross-thread calls for things like updating UI controls that utilize Invoke . I'm an amateur and have a hard time understanding the pros and cons of any particular approach. I am looking for some insight on which approach might be preferable and why. Update: This question is motivated, in part, by statements such as the following from the MSDN page on Control.InvokeRequired . An even better solution is

Which C# assembly contains Invoke?

孤街浪徒 提交于 2019-12-05 08:58:36
Alternate question: Why is VS10 so keen to complain about Invoke? In my continuing quest to make my app work become the worlds best C# programmer, I have decided that threads are a Good Thing™. MSDN has a helpful article on making thread-safe calls to controls , but it (and seemingly every other article on the subject) obliquely references a method called Invoke. Sometimes even BeginInvoke, which I've read is to be preferred . All this would be great, if I could get visual studio to recognise Invoke. MSDN says that it is contained in the System.Windows.Forms assembly , but I'm already 'using'