|
it hold that thread up until it re-activates
either in win or web
already in web the processor works parellarly with all client requests
it works in one page for a while and for example opens the DB connection and waiting data back in that stage it goes to another page and work and then get back to the first to continue when the databack then finish and goes to the second page to continue
this is more advanced technique than thread stop
the iis server who evaluates at which stage of code the processor can go to work in another page
|
|
|
|
|
So the thread simply gives up it's time slice to other waiting threads in the pool?
Cheers
Tris
-------------------------------
Carrier Bags - 21st Century Tumbleweed.
|
|
|
|
|
|
Thanks Colin,
One more thing -
Would it be efficient to do something along these lines:
<br />
SqlCommand.BeginInvoke(flags, callback)<br />
<br />
do<br />
{<br />
Thread.Sleep(0);
}while(cmdResponse == null)<br />
<br />
return cmdResponse<br />
And that should free up the db wait time for other requests?
Cheers
Tris
-------------------------------
Carrier Bags - 21st Century Tumbleweed.
|
|
|
|
|
Tristan Rhodes wrote: Would it be efficient to do something along these lines:
I'm presuming that cmdResponse will be set in the callback method on the other thread.
Tristan Rhodes wrote: And that should free up the db wait time for other requests?
What other requests? If my assumption is correct, you have taken an asynchonous request and effectively turned it back in to a synchronous request by waiting for the call back function to return.
Now, if you were to do something between the BeginInvoke and waiting for the call back method to populate cmdResponse then there might be some point.
When you are waiting for a database call to return from the server the thread will be blocked and the scheduler will skip past it until something is available for it to do.
|
|
|
|
|
I'm intrigued by the mechanics for this.
Clearly there is going to be a wait for the database response to process and return, and i'd like other threads to use that time instead of the current thread. I've been lead to believe that by performing a standard non async query, the thread is locked and not shared leading to a performance hit with lots of concurrent request, whilst performing a thread.sleep would enable it to be freed up and process other requests whilst waiting for the DB to response. In which case, wrapping an async operation in a Sleep loop would give up the thread whilst waiting for a response.
But i'm guessing i've got the wrong end of the stick. Where have i gone wrong?
Cheers
T
-------------------------------
Carrier Bags - 21st Century Tumbleweed.
|
|
|
|
|
Tristan Rhodes wrote: Clearly there is going to be a wait for the database response to process and return, and i'd like other threads to use that time instead of the current thread.
The thread will block while it waits for the network response. Just as it will block if it is waiting for a disk read and so on. While the thread is blocked the OS will switch to the next available highest priority non-blocked thread. The OS will not attempt to run blocked threads. So blocked threads will not take up processor time.
Tristan Rhodes wrote: the thread is locked and not shared leading to a performance hit with lots of concurrent request
Locking is a different issue.
Locking relates to resources. For example, if you are performing an update on an object that takes several lines of code the OS can interupt the operation and swap in a different thread (or the other thread may be running on a separate processor or core). Either way, while you are making the update you want to lock out any other changes so that your object remains in a consistent state. When you lock the object you block other threads from locking it at the same time.
If a thread attempts to lock an object that is already locked its will be blocked, the OS will move on to the next thread (the highest priority non-blocked thread). When the first thread releases the lock the second thread can then aquire it. For obvious reasons a lock should be aquired and released as quickly as possible, you don't want to block other threads too long.
Tristan Rhodes wrote: a thread.sleep would enable it to be freed up and process other requests whilst waiting for the DB to response
The thread will block anyway while waiting for the result set to return. You are just implementing what is already taken care of in the OS - and less efficiently because you continually wake up and perform a check then go back to sleep again. The synchronous database request will just wait (i.e. It will be blocked) until something is available or the operation times out.
Tristan Rhodes wrote: Where have i gone wrong?
By the looks of it confusing locking with blocking. I hope this has explained enough that you've got a better handle on the situation.
|
|
|
|
|
Sorry, i missused Lock in my last post, i know the difference.
Could you explain the benefits of using the Asynchronous PageLoad model in asp.net if, when waiting for requests from the database, the thread can process other incoming requests?
Cheers
T
Edit: Alternatively a good article will do. In the mean time, i will re-read the MS article on async programming model when i'm not so tired.
-------------------------------
Carrier Bags - 21st Century Tumbleweed.
|
|
|
|
|
Hi!
I'm currently writing a poker program i .net compact framework. In one method I have a while-loop that goes through every player until everyone is finished betting. What I need is some way to halt the while-loop until the user makes a decision (presses a key) and then continue. How can I do this?
Thanks!
|
|
|
|
|
Have a Timer Control with Enabled = false.
Place the code that you wants to execute in the Timer_Tick Event .
Enable the Timer when the user press a key(In the Key Down event).
Hope hat helps you.
Regards,
Arun Kumar.A
|
|
|
|
|
If i have total markup (XAML) based workflow, how do i refer some property/variable defined in my XAML inside rule file?
I know how we can do this using code, but i want to do this for pure XAML based workflows.
Any hints or examples would be appreciated.
Muhammad Shoaib Khan
http://geocities.com/lansolution
|
|
|
|
|
hi i am currently doing remoting in c#.net window application my server codes is below
i would like to ask if there i can put an event handler (function)
which will execute when there is an incoming request from the client
reason: as i need to reload the form when also populate one of the text box in the form when the request comes in
thx for reading
and hope you can help me pls
using System;<br />
using System.Collections.Generic;<br />
using System.ComponentModel;<br />
using System.Data;<br />
using System.Drawing;<br />
using System.Text;<br />
using System.Windows.Forms;<br />
using System.Runtime.Remoting;<br />
using System.Runtime.Remoting.Channels;<br />
using System.Runtime.Remoting.Channels.Tcp;<br />
<br />
namespace WindowsApplication2<br />
{<br />
public partial class Form1 : Form<br />
{<br />
public Form1()<br />
{<br />
InitializeComponent();<br />
}<br />
<br />
private void Form1_Load(object sender, EventArgs e)<br />
{<br />
TcpChannel channel = new TcpChannel(8080);<br />
ChannelServices.RegisterChannel(channel);<br />
<br />
RemotingConfiguration.RegisterWellKnownServiceType(<br />
typeof(ClassLibrary1.Class1),<br />
"HelloWorld",<br />
WellKnownObjectMode.SingleCall);<br />
}<br />
}<br />
}
|
|
|
|
|
I too am trying to work out how to do this.
What I know so far is that you need to use
WellKnownObjectMode.Singleton
When registering, this means that the server maintains 1 instance of the object and gives a reference (proxy) to this each time a client asks for it.
However How do we instantiate and get a reference to this object on the server side? so we can see the data its fields contain etc...
(Also remoting is not thread safe, AFAIK each remote call executes on an individual thread so you need to make them thread-safe).
Wilco
|
|
|
|
|
Hi
I have a problem with changing printer's paper size to custom paper size(programmatically).
I use PaperSize cunstuctor to create custom paper size and then assign it to PrintDocument.DefaultPageSettings.PaperSize.
this is not change paper size in printer.
Dim pd As PrintDocument = New PrintDocument
Dim pkCustomSize1 As New PaperSize("Custom", 100, 200)
pd.DefaultPageSettings.PaperSize = pkCustomSize1
Please Guide me
Thnaks
|
|
|
|
|
hi i am trying to do remoting so far i am able to connect but i cant seem to pass any data thru my code is as fellows:
i would too like to ask if my code is passing data from the sever to client or vise versa as i am a little confuse.
my server:
TcpChannel channel = new TcpChannel(8080);<br />
ChannelServices.RegisterChannel(channel);<br />
<br />
RemotingConfiguration.RegisterWellKnownServiceType(<br />
typeof(ClassLibrary1.Class1),<br />
"HelloWorld",<br />
WellKnownObjectMode.SingleCall);
my client:
TcpChannel chan = new TcpChannel();<br />
ChannelServices.RegisterChannel(chan);<br />
<br />
ClassLibrary1.Class1 obj = (ClassLibrary1.Class1)Activator.GetObject(<br />
typeof(ClassLibrary1.Class1),<br />
"tcp://172.17.168.51:8080/HelloWorld");<br />
<br />
try<br />
{<br />
if (obj.Equals(null))<br />
{<br />
label1.Text = "not connected";<br />
}<br />
else<br />
{<br />
label1.Text = "connected";<br />
}<br />
}<br />
catch<br />
{<br />
label1.Text = "not connected";<br />
}
my class:
public class Class1 : MarshalByRefObject<br />
{<br />
<br />
public Class1()<br />
{<br />
string abc; <br />
}<br />
<br />
<br />
<br />
<br />
}
as you can see my class contint a string abc i would like to ask how can i set it at my start and what code would i use to exttract it at the end side
|
|
|
|
|
Hi all..
Can anyone provide me with the code convertor tool...ie.the tool which converts the vb.net code to C# code and vice versa...
It would be better if the tool is an .exe..
Some one help in this regard as early as possible...
Note:Dont reply asking to try in google...
Regards,
Balaguru
|
|
|
|
|
Hi Balaguru,
First of all this is no service that you can get from this web site, that you can command for information. All you can do is to request for information, and be polite.
If somebody asks you to try in Google, it may be because its an obvious information. What you have asked here now is such a question. Code convertor tools are available in plenty and all you got to do is use google to find it. Forget google my friend, its available here in Code project.
http://www.codeproject.com/csharp/gbvb.asp
So first try some resources and only if you dont find any usefull information, post it here.
In my case, I dont have access to Google in my work place, still I post questions only after going through articles here. I do not mean any offence, but I hope many of our members would agree with me.
Regards,
Blumen
|
|
|
|
|
Hi Blumen...
I feel sorry if my post has insulted u...I dont find any commanding issues in my post rather i have made only a humble request..As like u i too dont have access to google in my office.Thats wat made me to make a note in my post.What happens is that we post a question and long for replies.If the reply simply comes try in google,its very irritating..Thats it..
Anyway i am sorry ...
Regards,
Balaguru
|
|
|
|
|
Balagurunathan S wrote: As like u i too dont have access to google in my office.
You need to make this clear. It's about the dumbest policy I ever heard of, so you're going to have to tell us that it's the case where you are.
http://www.tangiblesoftwaresolutions.com[^] is one of the hits I got with google.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi,
Your words dint insult me, I found it impolite, though. Anyways I hope you would have got useful information regarding the tool now. Try these as well:
http://www.developerfusion.co.uk/utilities/convertvbtocsharp.aspx
http://www.kamalpatel.net/ConvertCSharp2VB.aspx
Regards,
Blumen
|
|
|
|
|
Balagurunathan S wrote: Note:Dont reply asking to try in google...
So why is Google blocked at your workplace?
Yahoo too?
Seriously, all you had to do was type "vb.net c# converter" into either one and you'd come up with a bunch of them.
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|
|
Hi Dave,
I've no idea why Google is blocked here, thank god we have access to CP
Yahoo is not blocked, we can use Yahoo search, but can't open any results because those websites would be blocked. I believe they are restricting Internet access to maintain safety of the code and of the network, from hacks and viruses. We can't access any personal e-mail, i.e. websites like Yahoomail, hotmail, gmail etc.
I don't think situation is the same in all companies here, some companies give unrestricted access to its employees.
From which part of the world are you from Dave, and how is network maintained in your company? I'm from India. I hope its liberal there.
Regards,
Blumen
I wish to become a software consultant.
|
|
|
|
|
Quit and find a better company. Well, find a better compnay first, then quit. If the search engines are useless to you, I don't see how they can expect you to find solutions to problems without the 'Net.
I'm in the US and in the company I work for, there are no blocks on where I can go.
|
|
|
|
|
Balagurunathan S wrote: Dont reply asking to try in google...
Why not?
If google can't do it, then look at Sharpdevelop because they have a tool for converting VB.NET to C#. I haven't worked with it in a long time, so I don't know how well it converts...
|
|
|
|
|
SharpDevelope's conversion tool for VB-C# isn't that good. C#-VB support is OK though. I find that when converting VB-C# code, SharpDevelop doesn't take into account VB Optional keyword. It leaves it in there, and of course the C# compiler doesn't understand it. I had to really revamp my code and include support for multiple extra functions before I got my app working OK.;)
|
|
|
|