Thread.Sleep() Blocking NetworkStream.BeginRead() Call Back?
Jul 7, 2010
I create a NetworkStream from a TCPClient, I then call BeginRead() followed by Thread.Sleep(60000).
It seems that the BeginRead call back function will only ever occur after Thread.Sleep() has completed. Is this expected behaviour?
What I was expecting was for the call back function to be carried out on a separate thread whenever it was ready and that the Thread.Sleep() on the current thread should have no affect on when/how the call back function runs...
I'm currently creating a VT100 terminal emulator, I wanted to created a method that would allow me to make the emulator sleep until a given string is found in the screen buffer. Initially I was trying to call WaitOne() on the IAsyncResult passed back from BeginRead() if the string was missing (this was to allow more data to pass into the system so that the check could then be carried out again until it was passed), after this failed I tried Thread.Sleep instead of WaitOne() but this blocked my BeginRead call back from firing and I'm now I'm starting to think everything is running from a single thread...
View 3 Replies
Similar Messages:
Jun 25, 2010
I have a password page and when someone enters an incorrect password I want to simply foil a brute force attack by having
bool isGoodPassword = (password == expected_password);
lock (this)
{
if (!isGoodPassword)
Thread.Sleep(2000);
}
I would expect that this would allow all correct passwords without stalling, but if one user enters a bad password another successful password from a different user would also be blocked. However, the lock doesn't seem to lock across ASP.NET threads.
View 4 Replies
Aug 27, 2010
I want a example of multithreading .i want to use it in a web form not on console.i am using C#.net .and how to use thread.sleep method for a particular thread.
View 5 Replies
Mar 16, 2011
I want to introduce a slight wait during some testing functions, to simulate a server call. Is it sane to use Thread.Sleep(int) to introduce the wait or is there a better method to have the server wait?
Note, I'll be pausing long enough for me to visually see a sufficient lag, even tho I don't expect to see such a delay in the actual app. This is for me to visualize the actual delay that could occur.
I plan on running this both in the VS2010 local debugger webserver and in IIS 7. I'm on .NET 3.5
View 2 Replies
Nov 10, 2010
While passing through code in our project I came across a web method that had this code at the end of it:
thread.sleep(6000);
return true;
Now, this was done so the jQuery ajax call from the client gets delayed and the ajax animation will show for a little bit longer. This is very wrong in my eyes. There shouldn't be this kind of connection between UI and server side. If he wants the animation to take longer he can use the setTimeOut function in the client side. Here is my problem: how can I explain to the programmer why this is so wrong? Not just because the client/server thing, but why ever call thread.sleep on a website?
View 6 Replies
Sep 8, 2010
I maintain a ASP.NET web application that causes a user's network connection to reset for several seconds when it executes a procedure. Therefore, the page request times out on the user's end as they never receive the web application's response (the connection dies before it gets the response packet).
To resolve this situation, I was contemplating having the ASP.NET page execute an asynchronous function that incorporates a Thread.Sleep(5000); // sleep for 5 seconds before executing the connection reset This way, the browser has 5 seconds to receive the page's response before their connection resets.
I have concerns with using Thread.Sleep and asynchronous functions in ASP.NET though. I've never attempted to do it before, so I'm unsure of the potential problems it may cause. Does anyone see potential problems with starting an asynchronous thread that contains a Thread.Sleep in an ASP.NET application?
View 3 Replies
Jul 23, 2010
My application is showing lots of thread wait events in the GetScriptReferencesInternal method of ScriptObjectBuilder. I am running a load test with 150 concurrent sessions and in 10 minutes I see 1000 thread block events. Each event stalls the execution of the thread for an average of 6 seconds.
View 2 Replies
Mar 1, 2011
I was wondering whether HttpPostedFile.SaveAs function in ASP.NET C# is a blocking call.
View 1 Replies
Apr 2, 2010
I want to remove checked items from checklistbox (winform control) in class file method which i am calling asynchronously using deletegate. but it showing me this error message:-
Cross-thread operation not valid: Control 'checkedListBox1' accessed from a thread other than the thread it was created on.
i have tried invoke required but again got the same error. Sample code is below:
[code]....
View 1 Replies
May 21, 2010
The following code is part of a WCF service. Will eventWatcher take up a thread in the ASP .NET thread pool, even if it is set IsBackground = true?
[code].....
View 1 Replies
Dec 16, 2010
I have created thread pool which have 5 threads. Both of them will start when my application start up. The problem is I created so many objects in thread loop call back function on each threads, and the memory is increase by second when app running, this is thread loop call back function:
void ThreadLoop(){
while(true){
var checkItems = _workItems.Where(w=>w.ActivedTime > 3).ToList();
foreach(var i in checkItems){
_workItems[i.Id].ActivedTime = 0;
_workItems[i.Id].ExecutePostBack();
}
//Recreate new _workItems dictionary
_workItems = _workItems.Where(w=>w.ActivedTime > 0).ToDictionary();
// Sleep thread to free up momory
Thread.Sleep(1000);
// Call Grab collector free memory
GC.Collect();
}
}
I'm confusing that, is calling GC.Collect() on each threads like that good or bad ? Dose it cause bad performence ?
View 3 Replies
Jan 27, 2010
How can we debbug a multi-thread program to see local variables of each thread using visual studio 2008.
View 1 Replies
Nov 24, 2010
I'm new to threading and have used it successfully, but limited. I can spawn a thread and have the main thread reference variables in the spawned thread, but I don't know how to allow the spawned thread to reference (and update) variables in the main thread.
Any example threading code I've seen on the web appears to be WAY more complicated than what I do, so I am unable to understand or integrate into my code.
Here is a quick example of how I use threading:
[code].....
View 3 Replies
Sep 28, 2010
In my program there is a aspx page that contains wcf client, that so on calls wcf service located on same server.
I`v get this exception when my wcf client calls wcf service hosted in IIS on production server.
Ex. msg: Thread was being aborted.
Ex stack: at System.Net.UnsafeNclNativeMethods.OSSOCK.recv(IntPtr socketHandle, Byte* pinnedBuffer, Int32 len, SocketFlags socketFlags)
at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags, SocketError& errorCode)
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size) [code]...
I using PRTG Ipmonitor and it give me too many requests on "Requests Current" sensor.My site become anavailable in browser.If a delete this page that calls service all is gona be OK.
View 2 Replies
Mar 24, 2010
I am reading the Asp.net security documentation on msdn.I come across these tow terms and get really confused.
# WindowsIdentity = WindowsIdentity.GetCurrent()
which returns the identity of the security context of the currently executing Win32 thread.
# Thread = Thread.CurrentPrincipal
which returns the principal of the currently executing .NET thread which rides on top of the Win32 thread.
View 1 Replies
Jun 10, 2010
I have a VB.NET ASP.NET webserver program running. One or more VB.NET clients are making use of it. Nothing special so far. As far as I know, the server is not really aware of the clients. Clients can request data. But is it also possible to let the server call-back a specific client when something happens? So that the client doesn't need to poll?
To be more specific, this server is connected with hardware modules. Clients could be terminals that show the status of a sensor for example. When a sensor gives an "alarm" value, it would be nice if the server could pass that alarm towards the clients. Instead of letting the clients to check each X seconds if that alarm is active. Would be a waste of energy, especially because the chance this alarm goes off is almost zero...
View 15 Replies
Oct 7, 2010
I accept both C# and VB.NET
If you visit this [URL] and then click on the link like the image below you'll see in-line pop-up DIV which displays a busy status of Ajax callback before it displays the information. So, the information is not there yet until you click on the link.
I'd like to do the same but ASP.NET and jQuery.
View 2 Replies
Mar 14, 2010
I need to save a value to a session variable from a javascript function, and then be able to call this value back from the Session into another javascript function during post back.
How do you do this?
View 10 Replies
Feb 28, 2012
Is there any call back event for update panel??
View 1 Replies
May 7, 2015
I have image button in my page below is code
<asp:ImageButton ID="IMGmanage1" runat="server" onclick="IMGmanage1_Click" ImageUrl="~/image/viewpro.png" />
protected void IMGmanage1_Click(object sender, ImageClickEventArgs e)
{
Response.Redirect("view.aspx?BehCode=" + Request.QueryString["BehCode"]);
}
but when I click on image button below error happen:Invalid postback or callback argument. Event validation is enabled using <pages enable EventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page. For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.ArgumentException: Invalid postback or callback argument. Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page. For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.
View 1 Replies
May 7, 2015
Recently, I added a button, a textbox and a jquery code. On click of button the textbox value was been captured in the dropdown. All my code is working fine. But, when I fill the other data and submit the form, It gives me the below error.
Also see the code for reference:-
<script type="text/javascript">
$('#ctl00_ContentPlaceHolder1_txtOtherBusiness').hide();
$('#ctl00_ContentPlaceHolder1_btnbusinessAdd').click(function (event) {
event.preventDefault();
[Code]....
View 1 Replies
Mar 23, 2011
I need a way to block users from their IP if necessary. What's the best way to approach this? Can I use Request.ServerVariables["REMOTE_ADDR"] and store the ip address as a string in the DB?
View 3 Replies
Jun 15, 2010
I have built an online CMS that is forms authenticated. The CMS allows administrators to upload files to the website. These files are stored outside of the Forms Authenticated section of the site so that they can be accessed from another site I have built. This other site is also forms authenticated, so users must log in and then they can access the files on the CMS site. site1.com: CMS for administrators only. Site stores all the files. site2.com: Access site.
My second website (The access site), is basically an empty shell that is filled with all of its content through the CMS using an SQL database and then displayed on the page. This works fine as only authenticated users have access to the interface used to view and download the files. My problem was, even though there is no public interface to find the files, someone could surely type [URL] and the video would be available to them. I dont really know what to do here, is there any way that people could be blocked from retrieving the files like this?
View 1 Replies
Dec 9, 2010
I have an ASP.NET MVC application that use the default ASP.NET Membership Provider. My customer asked to implement a feature that prevent users to log in (for example for users that resign and leave the company). I cannot use the IsApproved flag of the Membership table because that field is used to confirm user egistration. Is there any built in functionality for doing this? What are your experiences in scenarios like this?
View 1 Replies
Jun 9, 2010
I have a client who wants me to block his site from certain countries. Each month I add all the new IP address ranges for these countries into a sql database. If the user has a blocked IP address, the site directs them to a phoney 504 error page. This way it doesn't appear that the site is being blocked, but rather is just having difficulites. Thats the way we want it.
It works fine however, there are some users (5%) who get a 500 error. No rhyme or reason. It works across all browsers and operating systems. I have no way of finding out why from my hosting service. I can't dupliate it. I have the following code that runs at Page_Init
[Code]....
View 10 Replies