COM Control Call From .Net Frequently Blocking For 15ms?

Nov 19, 2009

I have an ActiveX/COM control written in C++/MFC which processes video (ie. 30 frames per second => about 33ms per frame processing budget) Various rendering aspects of the control can be modified using Set calls on the control, which clients can issue at any time.It turns out that someone (Windows scheduler, .Net interop wrappers, MFC call dispatcher, memory allocator, garbage disposal ?) is quite frequently eating an incredibly long 15.625ms to make or return from the call into the control. Thats half my per-frame budget eaten by some gremlins in the runtime !

The control itself is - for historical reasons - written in C++/MFC. The problem happens when the control is called from C# as well as VB.Net. It happens on very different hardware (an HP Pavilion 2.8Ghz Pentium D, a Macbook Pro with 2.5 Ghz Intel Core 2 Duo running Parallels VM). Just how often this mystery hiccup of 15.625ms occurs differs between machines, but when it does, it is always 15.625ms exactly. Strange.

I have made a rather minimal test case that strips out all the video processing etc.First, I created an MFC/COM Control project in the Project Wizard of Visual Studio 2003 and left things at their default settings (Apartment threading etc.). Then I added a single user defined call TestCall() to the control which does nothing (manually since there is no more classwizard)

Then I created a VB Client program which instantiates the control. It endlessly calls the TestTiming() sub which times how long a single call into the control takes and prints out that time.The TestTiming call basically just does this:

Code: startTime = DateTime.Now Dim h = AxTestControl1.TestCall() endTime = DateTime.Now Dim ms As integer = endTime.Subtract(startTime).TotalMilliseconds

I print out calls that take 0 ms (well something less than 1ms anyway) as "." and for calls > 0ms I print out the actual ms. The output looks something like this:.15.625 ms.........15.625 ms.........15.625 ms.........15.625 ms..........15.625 ms..........15.625 ms...........15.625 ms..........15.625 ms..........15.625 ms

So some variable nr of calls that execute quickly, as desired, and then a "hiccup" call that always takes the exact same amount of time (15.625ms), then some more quick calls.If instead of the user defined control function .TestCall() inside the timing I use a standard control property, like

Code:Dim h = AxTestControl1.Heightor a built in control method like
Code:Dim h = AxTestControl1.ToString()Then I never, ever get a hiccup call.

On different machines you will get a different average number of "." before a hiccup but even then the hiccup is 15.625ms I should mention that the sample code spins off a background thread and calls the TimingTest from its ThreadTask(). This is the way the bug was originally reported to me. However, I can put the

Code:Do TimingTest()Loop

right in the main UI thread - as the first thing in Form1_Load() for example. And it will exhibit the same behaviour, except there will be substantially more good=0ms="." calls on average between the inevitable hiccups.

[code]....

View 1 Replies


ADVERTISEMENT

Socket Error 'A Blocking Operation Was Interrupted By A Call To WS?

Mar 23, 2011

making an sort server/client app and i can start the server and such... , but when i trie to stop the server i got this error:

A blocking operation was interrupted by a call to WSACancelBlockingCall
This is the code where i get the error:
Public Sub StartServer()

[code]....

View 4 Replies

Wpf - Microsoft Script Control - Blocking Scripts' Access To The System?

Nov 4, 2011

I am developing a commercial VB.net WPF application that needs user generated scripts for controlling the application to be shared between users. The best way that I have come across of accomplishing this so far without writing my own parser is using the Microsoft Script Control.

It would appear that both VBScripts and JScripts run through this control have access to wscript and as a result are too powerful to be shared between programmers and non-technical users for obvious security reasons. I have considered trying to filter out dangerous scripts with some kind of regex parsing or something but that just seems far too risky and easy to circumvent.

So, is there some way of using this control but blocking its access to the system so that it could be used for controlling only the objects that I give it? If not, could someone recommend a better way of doing this?

I do not particularly mind what language the script would be in at this stage, although having multiple options would be nice.EDIT: I am basing my conclusion that the control is too powerful for this on the fact that the following JScript code successfully launches notepad when called using the .AddCode and .Run methods of the control.

[Code]...

View 2 Replies

Manage Frequently Called WCF Connection?

Aug 13, 2010

I have a local service and a WinForms app that communicate via WCF, but I seem to end up with a lot of copies of this code in my application:

Public Shared Sub MyLocalMethod1()
Dim tcpBinding As New NetTcpBinding
tcpBinding.SendTimeout = New TimeSpan(0, 0, 5)

[Code]....

I should probably be doing this in some kind of a helper class that creates the connection, lets my service use it, and then closes the connection, so I don't have multiple copies of this connection code. However, should I be leaving this connection open, or does it make sense to close it every time? The WinForm generally calls the service every few seconds, so it may make more sense to try and have a common copy that all these different calls can each access, instead of opening a closing a new connection each time.

View 1 Replies

From HTML Content In A WebBrowser Control, Call Another Control?

Feb 20, 2010

I have a regular application form with a WebBrowser control.I have strung together a .htm file (from a regular text file) which I then assign to the WebBrowser control. In the html file, I have filenames mentioned.I am trying to string together the html in such a way as to give a clickable link or button that will parse into html and open the corresponding file in another WebBrowser control in VB.I have tried using VBScript and JavaScript to put a button in the html.As long as the function or sub I call is also in the same html document, it works, but I really need to transfer the control back into visual basic where I can do the heavy lifting I need to.can I just not do this as a regular VB application? Any way to do it without adding the complication of requiring ActiveX?

View 3 Replies

Call A Control Event From Within Another?

Nov 21, 2011

I have a menu item in a program that I'm working on called "mnuFileSave" The Click event goes through several "housekeeping" functions and calls the correct "Save" function.

Another menu item performs a function and depending on the results may want to call the "mnuFileSave".

I have tried RaiseEvents mnuFileSave.Click and get the error "mnuFileSave' is not an event of 'The_Entertainment_Collection.frmCollectionBook'

I have tried Call mnuFileSave.Click an get the error "Public Event Click(sender As Object, e As System.EventArgs)' is an event, and cannot be called directly. Use a 'RaiseEvent' statement to raise an event."

View 4 Replies

Call Vc++ User Control?

Mar 3, 2012

can i call vc++ user control in vb.net

View 3 Replies

How To Call A Button Or Other Control By Name

Apr 29, 2010

Rank beginner here. Please be patient. I have buttons on my form. I can programmatically alter their properties:

btn00.BackgroundImage = Image.FromFile(sGrid(0, 0))btn00.BackgroundImageLayout = ImageLayout.Stretch

So far so good, but how do I refer to a button without its name. For example, is there a Me function (or something similar) like there is for forms, so I could do something like me.backgroundImage=ImageFromFile(sGrid(0,0))

View 1 Replies

Call A Script From WebBrowser Control?

Mar 12, 2010

How could I call a script from WebBrowser Control?

Example:

<textarea class="watch-comment" name="comment" onfocus="yt.www.comments.watch5.inputFocus(this)" oninput="yt.www.comments.watch5.updateCount(this)">

Now I want to call this "oninput" script, so I can simulate clicking this textarea.

View 7 Replies

Call Function Outside User Control?

Mar 11, 2012

This is my first month for migrating from vb6 to vb.net.

i've simple code here :

this main form .:

Public Class Form1
Private Sub LinkLabel1_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel1.LinkClicked

[Code]....

View 11 Replies

Call To An IFrame Within A Webbrowser Control

Jun 21, 2010

I am using a Webbrowser control to sign into Hotmail. Then once it is signed in then I'll just use this navigate code to open the inbox: I think that the problem is that the actual inbox(mail window) is within an iframe. I have to figure out how to call within the iframe. If you can goto hotmail and sign in and you'll see once your in the inbox when you view source it isn't the inbox's source but then when you right click then goto this frame then view the source to the frame it is.

[Code]...

View 3 Replies

Blocking A Website Through I.E?

May 4, 2010

I was wondering if it would be possible to block a website, such as "www.proxy.com"
Through Internet Explorer, not one of my custom ones of my form.

View 8 Replies

Blocking In A Service?

May 25, 2012

The subject sucks, but the problem is straightforward. I have an existing WCF service. There are a small series of functions, currently. One or two of the functions will need to be performed with a bit of security, for which I need a username and password. The username and password will be checked on the server side against a webservice running on localhost. One alternative is to not use the localhost webservice for the validation, but then I wouldn't have a question, so ignore that.

The way the webservice will work, I was thinking that I would use an invisible web browser, navigate to the REST-style URL, and wait for the response. It's the bit about waiting for the response that is causing me trouble. Normally, I'd wait for the document comleted event raised by the browser control, but since this is initiated by the call of a WCF service function, that won't really work. The WCF function call can't 'wait' for anything, nor will it receive the event. Once the WCF function reaches the End Function statement, it is over and done with, and returns. The response from the webservice won't have arrived by then, so that won't work. There are two typical solutions to this, one of which is horrible to the point of being unworkable.

1) A busy wait, or spin wait, where the WCF function goes into a tight loop waiting for the browser event to be raised. This is never a good idea, and is particularly terrible in this case, because the WCF service is running on a web server, so the negative impacts of a busy wait are FAR worse than normal.

2) Use something like a Mutex in the WCF function such that the function launches a thread, the thread immediately grabs the Mutex, then begins the navigation. The WCF function waits on the Mutex, which would mean blocking without spinning, and the document completed event pulses the Mutex to release the WCF function so that it can return the proper response. This seems technically improbable, as it stands.

The problem is only a slight variation on a very typical problem, yet it presents some interesting problems. Windows is event driven, but a WCF service function is not. A callback across a WCF (at least across this one), isn't an option, events aren't an option, so it all comes down to the function starting a process, then blocking without spinning, until the process comes up with an answer.

View 11 Replies

C# - Blocking A Thread In .Net?

Aug 13, 2010

I have a class that has purely static Methods and properties. I am calling an async method on the class "Load" that asks a web service for a chunk of data, which then fires an event that executes the return method, "LoadCompleted". I have no idea how long the call is going to take (the difference between calling the "Load" method, then the "LoadCompleted" getting called).

I would like to block the application from proceeding any further until the callback method has been raised (as the app will try and get stuff from this class, which isn't populated until the "LoadComplete" method sets the data).

View 3 Replies

Call Button Event From One User Control To Another?

Oct 28, 2011

I have created two user controls (lets say A and B) and calling then on default.aspx. Both user controls have button named as clear and its event method "btn_clear_click (sender,event)". Actually I like to do something like this: if I click clear button of user control A then it would also do the same tasks defined in user control B's bth_clear_click method. Means, is there any why to call button event of one user control in another user control.

View 2 Replies

Control Not Updating From Cross Thread Call

Oct 10, 2010

I have a few classes. One of the classes handles everything to do with updating controls (Such as adding items to a listview, etc.) and another is handling loops. I'm trying to add something to a richtextbox from another thread.[code]..

View 3 Replies

Blocking An Ip From Connecting To Computer?

Sep 20, 2009

I am trying to make an app in VB.NET that pings ip's on a specfic port that are connected to my computer and if it is greater then 500 the person would be blocked from connecting to my computer. How can I do this in VB.NET?

View 1 Replies

Blocking Web Sites In Browser?

Oct 10, 2009

I am creating a security program. One of its features is that it blocks inappropriate web sites. I might need help determining which sites are bad and which ones are good. If I could 'read' every work that is displayed in the browser then I could tell, but that may come later.

So, I'm looking for some kind of hook that will allow me to cancel the site if needed. It should be able to still be hooked in Safe Mode, as well... I'm sure that this is going to be an easy one!

View 7 Replies

Blocking Websites With Browser

Sep 9, 2010

I wish to block websites in a browser, where the blocked websites are stored in my.settings.blockedwebs (which is a collections. specialized. stringcollection). I let the user input the blocked website into a textbox in form1, and the add website to the stringcollection button has the following code:[code]

View 15 Replies

IDE :: Make Firewall Blocking?

Jul 27, 2009

I am unable to get on to internet explorer or IM on my laptop . I am using Windows XP.Each time I log-in it says my firewall is blocking.

View 4 Replies

Non-blocking Task.wait In .NET 4?

Apr 30, 2012

I'm trying to wait for a Task result in .NET 4, much like you can by using the await keyword in .NET 4.5. I just can't figure out how to do it though...My code (to prove that I'm atleast trying):

Private Function GetXDocumentFromWebLocationAsync(ByVal request As WebRequest) As XDocument
Dim queryTask As Task(Of WebResponse)
queryTask = task(Of WebResponse).Factory.FromAsync(AddressOf request.BeginGetResponse, AddressOf request.EndGetResponse, Nothing, Nothing)

[code]....

As you would expect, the GetResponse calls are executed on a different thread, but the function has to wait for the result before it can return. Unfortunately this blocks my main thread until the task has completed and I don't have the slightest clue on how to make it wait without blocking. I don't want to use the Async CTP either because that's just running away from the problem.

View 1 Replies

Call Com Function - Control A Commercial Backup Product

Nov 29, 2011

I'm writing a VB.NET app that will control a commercial backup product. One of the things I need to do is loop through all existing jobs and look at the source drive. I am able to do this in VBScript very simply like this:

[Code]...

However nothing I try in VB.NET works. I'm pretty sure it has to do with the fact that the com functions are returning variant data types and arrays (specifically GetVolumes). I have tried using string arrays, object arrays, and even wrapping the return value in a VariantWrapper and I always get errors such as "not implemented" or "the parameter is incorrect." If anyone is bored and wants to write some code I'll gladly give it a shot and report back.

[Code]....

View 2 Replies

Tabbed Control Form - Procedure Call Does Not Fire

Mar 6, 2012

My main form is a tabbed control with 2 tabs. The first tab is has two listview controls which display information about the current machine. The second tab contains a treeview control and two listview controls. This tab recreates the device manager in windows. I created a Machine class to gather the information about the machine that I want to display to the user. When I call the Display() Method from my form's load event everything appears to be fine the first tab's information is displayed in the listview controls.

Here's the kicker, when I click to the device manager tab there's nothing there. The LoadTree() procedure never fires. This code works, I've seen my device tree display a thousand times in the past. When I comment out the call to Machine.Display() my device tree reappears no problem. The code compiles fine no errors. I know the problem has to be in my Machine class but I have no idea what could cause this kind of response. I've never seen a program compile clean and then refuse to fire a procedure call but not produce some kind of runtime error.

View 16 Replies

.net - Synchronous Wait Without Blocking The UI-Thread

May 24, 2011

Is there a synchronous wait function that won't tie up the UI-thread in .NET WPF? Something like:

Sub OnClick(sender As Object, e As MouseEventArgs) Handles button1.Click
Wait(2000)
'Ui still processes other events here
MessageBox.Show("Is has been 2 seconds since you clicked the button!")
End Sub

View 1 Replies

ActiveX Blocking Functions Freezing The UI

Aug 27, 2010

Is there a way to include an ActiveX to VB .NET project without adding it to a form?

If I add it to the form and call a function on it that blocks, the UI is unresponsive until the function returns. Even if I am making the call in a different thread.

I was able to compile the code when I did not include it via the form, but got this error once I called a function on it.

Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))

How could I make the UI responsive when the ActiveX functions are blocking?

View 7 Replies

Avoid Assembly.LoadFrom Blocking?

Jul 31, 2011

I create a .net dll on the fly with codedom then I load it with Assembly.LoadFrom like this:

Private Sub Test()
Dim ASM As Assembly = Assembly.LoadFrom("test.dll")
'Do some stuff with the loaded assembly...

[code]....

View 1 Replies

Blocking A Thread To Wait For Callback

Jan 19, 2009

I have been reading the async design patterns on MSDN and the general idea makes sense to me but in practice it is proving to be more difficult. I am working on a project utilizing VMWARE VIX.

HTML Code: [url]. Each function such as connecting to a host server, retrieving properties, etc. can be executed in two different ways.

Connecting to a host using a blocking Wait:

Code:
Dim m_lib As New VixLib
Dim m_hostJob As VixCOM.IJob

[CODE]...

Code:
Dim m_lib As New VixLib
Dim m_hostJob As VixCOM.IJob
dim m_callback as VixCOM.ICallback

[CODE]...

The problem with the VIX SDK is that sometimes the functions never return, hanging the application. dblock.

HTML Code:[URL] came up with a library that specifies a timeout value. When the timeout runs out the method aborts and returns regardless whether it finished or not.

The callback method is an active wait where the code continues to execute. What I want to implement is a blocking wait with a timeout. The ICallback interface has one sub OnVixEvent(IJob,Integer,IVixHandle). This method is fired at least twice, first when some progress is posted and second when it is complete. The first call to this method can be one second after registering the callback or 30 seconds, so I can not rely on this method to block the main thread. how to create some kind of async result class that would block the main thread from executing until either a timer runs out or the OnVixEvent method returns an Operation Complete signal that also implements ICallback.

View 10 Replies

Blocking List Of Process With Timer?

Apr 11, 2012

I am trying to block a list of processes from Txt file/ Listbox System.Diagnostic.Process using Timer. Here's the timer codes

[Code]...

I can block processes from the list using SelectedItem, but it doesn't block all the process in the list.Using while loop causes a deadlock error here. I'm now using aBlock.ReadLine to read from txt file and block the available process. However it is only able to block the first process. Need some guidance to get this code to block all the processes in the list.

View 5 Replies

C# - IO Operation Is Blocking UI And Background Thread

Jun 29, 2011

I am a novice in Threads, but I want to know how to order thread execution in my scenario, and is the following :

UI Thread : Windows Form Background
Thread : Kind of print daemon
implemented with recursive methods
IO Operation : a StreamWriter that do
the job of File.AppendText()

When I execute my main app.exe, sometimes it launches the Windows Forms and the execution process in the task manager (app.exe), in some opportunities its just launches the execution process in background. How can I determine the behavior of launching UI, I have to establish a priority or somewhat else? Code: I'm using framework 2.0 and any answers could be writted in C# or Vb.Net.

View 1 Replies

Programmatically Webpage Blocking / Filtering

May 24, 2009

how to or have a tutorial about programaticly blocking a webpage from webbrowsers? or is this not possible because it would need to be done on a router level?

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved