|
I wasn't being ironic, but yes it was a refreshing change of post.
Yes it is important to learn, however, learning also means knowing what resources you have available. From a project management perspective I'd be a little ticked off that he spent two hours struggling with something when help was available.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
I'll disagree with your disagreement.
From a project management perspective I'd be a little ticked off that he spent two hours struggling with something when help was available.
Knowing what resources are available is also part of learning, Google isn't the only source.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Ok and how many developer you met in your life working on your projects and asking for "How can I retrieve something from database?" or "How to open a window or retrieve form data?"
There is a big difference between project work and learning!
For someone who learns how to develop something its really
a better practice to find the problem and the solution for his own!
If you work on a project, I would assume that you can develop, know the important issues and the technics, how to go on problems and solve it. So I really would kick as...es if someone idles on a problem and does not say anything, but the time runs.
Google isn't the only source.
There you are right, but I really often read some questions here, where I only have to type 2 words in
google and I will find a solution. But of course, querying someone else and be lazy is simpler!
If you meant me with the "google"-thing. So I only have to say I taught myself how to develop programs,
spent hours for hours trying to achieve my own goal (to a time where the internet was in diapers ).
Knowing what resources are available is also part of learning
This is also right.
But here is something I said before:
If someone succeeds in querying for help, every time he spent more then 10 minutes on a problem
without solution, why should she/he learn how to solve problems on her/his own if he/she can ask someone?
So if your best source is somebody you can call guru, and query him every time, whats the reason,
to learn it on your own? (This applies very often to "newbee"s, who wants to achieve a goal that
doesn't match with their own skills.)
Finally:
Sometimes its better not to help somebody, cause it strengthen its skills!
Greetings
Covean
|
|
|
|
|
Covean wrote: So if your best source is somebody you can call guru, and query him every time, whats the reason,
to learn it on your own? (This applies very often to "newbee"s, who wants to achieve a goal that
doesn't match with their own skills.)
You are missing the point. The OP was not in a learning environment, he/she had co-workers available and eventually asked for their help; just waited much too long to do so.
If one is constantly asking for help and not doing at least something on their own, thats one thing. If they attempt it, realize they don't know, then ask for help, that is learning.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Ok maybe you are right in the fact that he waited too long.
(Didn't realize that he wasn't in a learning environment.)
But what does "realize they don't know" really mean.
Not to know how to start? Or not to know how to solve
the last 20% of a problem? At what stage should somebody
realize he/she will fail with his/her attempt?
At least the last question is hard to answer.
I will not disagree with the fact that this is learning,
but there are many ways to learn something and the best
way to do so is learning by your own faults.
Greetings
Covean
|
|
|
|
|
Ok, so I have been trawling the web to try and find an answer to this, but to no avail.
Basically, I have a DirectShow filter (well 2) which will allow me to configure a Hauppage WinTV USB adapter (though I doubt the specific filter is 100% relevant to answer the question) to use PAL (I) and to set the source as Composite In. So far, I have found ways to display a filter's property page, and to change the settings of a DMO filter, but not enumerate and change the properties of a non DMO source filter.
The reason for needing to do this is that both filter options seem to reset with Windows, meaning that our source becomes NTSC and Tuner In, rather than Pal-I and Composite In. The filters are classed as a Video Capture Source (WinTV HVR-900H Capture) and a WDM Streaming Crossbar Device (WinTV HVR-900H Crossbar), but the ability to change any property of any filter sans a GUI will be a step in the right direction
I am using a .Net wrapper to play with the filter graph through c#, but have limited knowledge of COM interop (thus the wrapper).
What's the easiest method to go about this?
|
|
|
|
|
Use the (free) program GraphEdit to create the graph exactly as you want it, and save the grapf (.grf) file on harddrive. In your code create a graph object which loads the grf file... This should bring you close...
|
|
|
|
|
Wow, I didn't realise you could simply load a grf file, I've already got one of those on my machine with the correct settings. ;o) Do you know which Graph object I need to create? And which method would then open the file?
Thanx for the swift response btw.
|
|
|
|
|
Try the DirectShowLib[^]. This library probably contains everything you need (even a graph object). You only need to glue them together.
|
|
|
|
|
Again, Eduard, thanx for the swift reply. =]
I'm actually using (or at least, trying to) this library already, but having not used Direct Show in a long while I don't remember how to instantiate the correct Filter Graph from the dozen different FilterGraphs, and definately wasn't aware that you can then import a grf file. When you get another moment, would it be possible to point me in the direction of instantiating the correct Filter Graph?
|
|
|
|
|
I want to save fingerprint image into database, I am using ActiveX FpLibXCapture to capture. I am able to capture and paint on picturebox
but picurebox.image is null. bellow is the sample.
axFpLibXCapture1.Capture();
axFpLibXCapture1.DrawImage(pictureBox1.Handle.ToInt32());
can any one tell how to get painted image from picturebox. Thanking you.
modified on Thursday, November 12, 2009 8:21 AM
|
|
|
|
|
Message Closed
modified 23-Nov-14 7:03am.
|
|
|
|
|
super answer, works without prob.
Thanks
|
|
|
|
|
I'm making a few assumptions on what you're doing and why you're saving the image of a fingerprint in your database, so...
It may work, but what are you really getting?? I don't know anything about the control you're using, but, is the image being "snapshotted" from the PictureBox at the native resolution of the conrol?? My bet is probably not. So, what you're taking a snapshot of is a lossy, scaled version of the data making up the fingerprint. You're not saving the full resolution of the fingerprint image in the database.
|
|
|
|
|
I do agree your point, client wants finger print image to be printed on glossy paper. One more thing! I made picturebox autosize, I may not loose resolution/data(am not sure about it). Important thing is finger print here not for maching.
Thank you
|
|
|
|
|
Scaling up a screen shot image to a printed image will result is "jaggies". You'll get a much lower quality output on the printer. Unless, of course, your printed image is the size of a postage stamp...
|
|
|
|
|
Hi,
Thanks for reading this!
For the people who never read any of my posts I am trying to write a proxy server in c#.
I am trying to "keep it simple" and stay away from asynchronous requests, but is not possible to totally avoid threading and I think I am encountering some multi threading problems.
The idea is to have a listener socket, binded to a certain prefix. Whatever requests I get there, I append them the correct credentials and send them straight to the (atuthenticated) server on the other side; then I grabb the bytes of the response and show them in the browser. For this I am using the HttpListenerContext class.
public void Start()
{
try
{
m_listener.Start();
while (true)
{
try
{
HttpListenerContext request = m_listener.GetContext();
ThreadPool.QueueUserWorkItem(ProcessRequest, request);
}
catch (Exception e)
{
System.Diagnostics.Debug.WriteLine(e.ToString());
}
}
}
catch (Exception e)
{
System.Diagnostics.Debug.WriteLine(e.ToString());
}
System.Diagnostics.Debug.WriteLine("Listening socket on port " + m_port);
}
The function ProcessRequest does the actual job that I wanted. (note that it does it in an asynchronous way!)
private void ProcessRequest(object listenerContext)
{
try
{
var context = (HttpListenerContext)listenerContext;
try
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(address);
Stream instream = context.Request.InputStream;
Stream outstream = response.GetResponseStream();
instream.Close();
outstream.Close();
context.Response.OutputStream.Close();
}
catch (Exception ex)
{
}
}
catch
{
Restart();
}
}
Normally, everything goes ok; however, whenever I have a client that does a lot of requests very quickly (almost parallely) there is a problem in line writing the output stream (with the bytes that I just grabbed from the server) and an error is thrown:
An operation was attempted on a nonexistent network connection
This is misterious; is the network connection referring to the incoming stream (the server that I am comunicating with)? if its there is no apparent problem, because I checked and the connection is still on... or is this connection referring to the output stream? if it is, there is also no apparent problem cause I checked it with the functon [i]CanWrite[/i] and it returns true, so it is looks in good health;
If anybody has any "light" to to bring into this question I would really appreciate it, cause I googled it to exhaustion and did not come to any conclusions
Anyway, moving on: I caught the error and figure out that I need to somehow close the streams that are opened; I did not find a clean easy way to do it (cause I cannot access the streams anymore), so the "brute-force" approach was to close the actual listener and start it again (so that I can again listen for connections);
private void Restart()
{
Stop();
Start();
}
Most of the times, this is ok, but sometimes, when I enter the [i]Start()[/i] function, there is a problem with this line:
HttpListenerContext request = m_listener.GetContext();
and an exception is thrown:
The I/O operation has been aborted because of either a thread exit or an application request
and then I am in a bit of a mess.
Apart from trying to solve this particular errors that cause my application to fail requests once in a while, I am looking at the bigger picture and wondering if the issues I am encountering are from not approaching properly the situation; am I having simultaneous access to the code and no handling properly the multithreading (I actually tried a lock() of the critical section without any improvement...) ? do I need multithreading here? or is it something else?
As I said, any help here would be much appreciated! Thanks in advance
|
|
|
|
|
Hi there, I'm not the lightbringer but I have an idea where the problem can be.
try
{
HttpListenerContext request = m_listener.GetContext();
ThreadPool.QueueUserWorkItem(ProcessRequest, request);
}
catch (Exception e)
{
System.Diagnostics.Debug.WriteLine(e.ToString());
}
"HttpListenerContext request = " is an variable thats scope starts with the { after the
try and end with the } before catch. So its only valid within this scope, after this scope
the garbgage collector can decide when it will dispose it (should be an object of generation zero).
So I think you should assure your context lives longer.
Greetings
Covean
|
|
|
|
|
Hi,
I don't think so. request is passed to QueueUserWorkItem which is bound to store it somewhere (in the TP queue) hence it will stay alive until executed.
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
Yes you seems to be right I tested it, and it really lives as long as the thread lives. However
I run in exactly this problem someday where the gc killed thread objects, which I had to force to be
at least an object with a mid-ranged lifetime-cycle otherwise the app chrashed after a while.
So I thought this can be a reason, but it wasn't.
To your solution: I only worked one time with ThreadPools, after that I loved it to do this on my own.
[edit] did some typo
Greetings
Covean
|
|
|
|
|
Hi,
I think your problem is in using the ThreadPool.
The TP holds a large number of threads, and has a queue into which you can insert jobs. Now those jobs get executed by some number of TP threads; however that number does not equal the number of available jobs: it starts of at a few only, and will grow and shrink using a complex algorithm. In one of my experiments I noted it only grows at a rate of 2 per second. Therefore your jobs will queue up and wait on others to finish first, which is not what a normal server does (it either accepts the job or refuses it, but never postpones it).
So IMO you should use either real Threads or (more unlikely to succeed) use asynchronous operations. BackgroundWorkers would not help as they run on the TP as well.
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
Ok, thanks a lot all for your answers.
So I think the summary of the situation concerning multithreading in C# is (correct me if I'm wrong):
- use asynchronous requests and let the system handle the multithreading; (1)
- use threadPool and let the system handle the multitreading (distribute tasks among worker threads); (2)
- implement "real" multi threading, handling synchronization, locks, etc; (3)
I wanted to keep it as simple as possible, without having to write a lot of "thread" of code (unless absolutely necessary), so I tried to stick to option (2), which as Luc Pattyn mentioned, has some limitations but I think I can "live" with them (that is, the app fails sometimes, I can catch the errors and carry on without major implications for the user).
One thing that I amended in my code, was removing the "restart" of the listener on the event of an exception; there is no need to stop and start the listener on error, and in fact, when I had a lot of threads running, the "restart" of the listener itself was a cause of problems...
The I/O operation has been aborted because of either a thread exit or an application request
So, after refactoring my "ProcessRequest" callback, it now looks like this: no restart of the listener and separate handling of different types of exceptions; one important thing is to close the Context.Response after an error, so that it sends a response to the client;
private void ProcessRequest(object listenerContext)
{
try
{
byte[] buffer;
var context = (HttpListenerContext)listenerContext;
try
{
Uri aUri = context.Request.Url;
string url = aUri.AbsolutePath + aUri.Query;
System.Uri uri = m_service.GetUri();
string address = uri.Scheme + "://" + uri.Host + ":" + uri.Port + url;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(address);
instream.Close();
outstream.Close();
context.Response.OutputStream.Close();
}
catch (System.ArgumentException ex)
{
context.Response.StatusCode = int.Parse(ex.Message);
context.Response.StatusDescription = GetStatusDescription(context.Response.StatusCode);
byte[] buff = System.Text.Encoding.UTF8.GetBytes("<HTML><BODY><b>Proxy Failure:</b> (" +
context.Response.StatusCode + ") " + context.Response.StatusDescription + "</HTML></BODY>");
context.Response.ContentLength64 = buff.Length;
context.Response.OutputStream.Write(buff, 0, buff.Length);
}
catch (System.Net.HttpListenerException ex) { }
catch (System.Net.WebException ex)
{
int status = (int)((HttpWebResponse)ex.Response).StatusCode;
context.Response.StatusCode = status;
context.Response.StatusDescription = GetStatusDescription(status);
context.Response.Close();
}
catch (Exception ex) { }
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex.Message);
}
}
It's not the best solution, has it fails to deliver some jobs (not properly handling the multithreading), but its kind of working and is simple.
cheers,
Jo
|
|
|
|
|
Hai all
I would like to know how i can convert office 2003(.doc) to pdf using some open source library dll's. I was successful in converting office 2007 files to pdf. I used different opensource dlls like itextsharp,sharppdf etc... but they wont take any .doc files for conversion. We can only create an entirely new pdf document out of it.
Friends any help is greatly appreciated...
I was behind it for quite amount of time
Thnx n advance...
Santo
Santhosh
|
|
|
|
|
I display some jpeg images loaded from Stream object in dynamicly created PictureBox component.
void function(Strean jpegStream)
{
Bitmap img = new Bitmap(jpegStream);
}
While 96dpi images are displayed correctly, some of the non 96dpi jpegs, e.g. 72dpi, 480dpi which come from photoshop or digital cameras get corrupted after I attach them to Image property of the PictureBox component and they are displayed.
As though half of the jpeg or more were not decompressed, leaving bottom half of the image grayish.
However if I delete and create again PictureBox component, and attach the same Bitmap object img again, already created from jpeg stream, they are correctly displayed???
Чесноков
|
|
|
|
|
Erhm, it seems there's no problem with the dpi's but more with the files itself. Your JPEG compression may be corrupt or something, but I would say the JPEG compression method is not great.
|
|
|
|
|