|
I need to use ffmpeg encoder in asp.net c#, but I cannot run by asp.net by itself. I'm new on this. Can somebody guide, or help me to create a wrapper or anyway that I can access frmpeg from asp.net c#.
Rafael
rafaeltejera@hotmail.com
Rafael Tejera
|
|
|
|
|
Can anybody shed some light. I'm a bit confused. Still a noob at C#. I read that Global variables are not supported in C# yet it seems to work for. They recommend you use struct instead but I can't seem to get it to work for me. I'm having a hard time understanding to program a string that can be accessed by any function without having to pass the String contents to the function. Basiccaly I need to access some strings globally. Any suggestions?
|
|
|
|
|
Make the strings static members of a class (eg: StringHolder ) and refer to them from any class in the following manner:
public class StringHolder
{
public static readonly string SomeString = "hello";
}
public class ReferringClass
{
void someMethod()
{
string foo = StringHolder.SomeString.Reverse();
} /ravi
|
|
|
|
|
There are global variables in C#.
Just create them outside the functions.
For instance:
public class Circle
{
double radius = 0.0;
double pi = 3.14;
public Circle(double Radius)
{
radius = Radius;
}
public double Area()
{
return pi*Math.Pow(radius, 2);
}
}
Best regards!
Larantz
|
|
|
|
|
Larantz wrote: There are global variables in C#.
Just create them outside the functions.
They are not global. They are members of the class.
---
single minded; short sighted; long gone;
|
|
|
|
|
Yes I know that works. I been programming that way all along but I just upgraded to Vista and downloaded the latest C# version. One of the note I read claimed it does not support it so I'm weary programming that way in xase it sops working in the future.
See this link
http://tinyurl.com/29o64p
http://tinyurl.com/29o64p[^]
|
|
|
|
|
Hi,
I am very new to c#. I have created a com object in c# and am using it from vba. it is working fine since until now i only needed to pass variables from vba to c#. I would like to pass a function pointer so that c# can callback a function in vba. any idea if this is possible?
thanks
|
|
|
|
|
Hello All,
I need a guidance on following:
1. I want to crate a windows application with Form or dialog the application behaviour is such that,
it shows a dialog or Form to user and simultaneously,
2. it process the data by listening to seria port and notifies on the form if a specific data is received.
(I know how to implement in VC6)
3. when I open a VC#.Net application wizard it gives me a form class , but I am not able to find the place where to add a code for serial port because the form is run by application thread and is blocked once the Application.Run is called.
4. To simplyft points above , I want to change the text of a form text box after the form is displayed.
Please see the below code for clarity:
namespace WeighbridgeManager
{
static class WeighbridgeManager
{
///
/// The main entry point for the application.
///
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
My Form WBScreen = new MyForm();
Application.Run(WBScreen);
//WBScreen.txtSomeTextBox.Text = "Hello World!!!";
}
}
}
The commented code never executes, I guess I am missing some threading logic here.
Thanks.
To simplyfy the problem, take it this way.
I want to change the text in the Form commented part and where to place this text.
La
|
|
|
|
|
Think of the Application.Run() command as starting a loop that continuously looks for updates and messages from inside the form that it is running. Any code after the .Run() will not execute until you close the form that is open.
Thus, you must put code that you want implemented INSIDE of the the form that you created. So inside your WBScreen class, on your Form_Load (or constructor, or whenever you want it executed), place the code that you want to run.
|
|
|
|
|
Hi,
To add to what Phil told you, a Form normally is "event driven"; everything
it does, is triggered by some signal that causes it to execute a "handler".
Examples:
when the form is first loaded (so it can become visible), it executes a Load event;
if you add an appropriate OnLoad(...) method, that will run then (just once).
when you add a Forms.Timer that will cause a particular method to be called
periodically
when you add a SerialPort in your form's constructor, that SerialPort has a
DataReceived event, that could call one of your methods every time a specified
amount of data has been received.
A lot of the words in the above are keywords or even class/method names;
look them up on MSDN to get all the details.
I strongly suggest you get acquainted with Forms, Buttons, events and the like long
before you start working with the SerialPort class !
|
|
|
|
|
Hello Phil,Luc,
Thankyou very much for the guidance.
I did a brief study of what you sugested, article (http://www.codeproject.com/csharp/workerthread.asp ) states what you described.
I am coming up following approach mainly based on the link I have given above:
1. Create a worker thread in the form class which will liten to serial port.
2. Keep on apending the serial port data as and when received by a deligate to form.
3. To get the text of a form's control, Call a deligate in worker thread which will return string by calling a function in form class to get the control's text.
Please suggest.
Thanks and Regards.
Amarjeet.
|
|
|
|
|
Sounds good to me, with one comment:
"3. To get the text of a form's control, Call a deligate in worker thread which
will return string by calling a function in form class to get the control's text."
You could do the append logic in the delegate (and hence in the form class) itself,
so to the worker thread it would mean: "here is new data, deal with it",
and to form would take it to mean "I have got new data, I should append it to
the previous data and update the GUI".
Warning: the packets in which you will get data will be arbitrary, not necessarily
entire lines of text, or entire units of whatever data structure they represent.
|
|
|
|
|
Hello Luc,
Thanks for the prompt reply and validating the approach.
What I understand from your comments in point 3 is:
3. I should keep sending the data from worker thread and let form append it?.
got it.
what I actually mean by point 3 beside this appending , I also needs to be quering on the form data For Ex: I have appended form text to 'Luc' and if textbox is not null and is 'luc' now do something else...
My understanding for the above is , to know the text of a text box any point of time , call a delegate from worker thread returning string with calling function on the form.
Is that right approach?
Secondly:
your warning comments mean what ? I did not follow that. please elobrate.
|
|
|
|
|
Hi,
what I meant was: make a clear split in functionality, try to define the work
in the worker thread with a clear border; it could be "take care of serial
communication", if so it would not know what will happen to the resulting data,
it would not have to know about the GUI, etc. That's a clean approach; and
later on you could reuse the worker thread's code.
But it you give it some other definition, that can be fine too.
The warning is this:
suppose the target (the other side of your serial cable) sends two strings
"aaaaaaaaaaaaaaa" and "11111111111111" one after the other.
Then it would be wrong to think you will receive first "aaaaaaaaaaaaaaa" and
then "11111111111111"; it might well turn out to be
"aaaaaaaaaaaaaaa11111111111111"
or "aaaaaaaa" and "aaaaaaa11111111111111"
or "aaaaaaaa" and "aaaaaaa11" and "111111111111"
That is, it is not because you are thinking about messages, that it will get
received as complete messages, the serial port does not care about anything
larger than a byte.
|
|
|
|
|
Hello Luc,
your points are well taken.
I should rethink my approach as My serial port management is real complex, to share with you, it's a controlling two device circuits boards through two serial COM ports simultaneously.
These device boards in turn needs to contol Weighbridges H/W like weighing scale, traffic lights, positioning beams etc.
My confidence is getting better after discussing with you.
Please stay tune.
Very best Regards.
Amarjeet.
|
|
|
|
|
Additional information on the messaging stuff:
when operating in synchronous mode and expecting text, you can do ReadLine()
to get an entire line of text; that's one way of dealing with textual messages;
of course you could use the synchronous mode in a background thread.
In case of binary data it seems you can't tell the system to return as soon
as a particular byte value gets received (although that functionality exists
in Win32).
|
|
|
|
|
Hi,
Ive got a filename that i'm passing to an stored proc, but the string is a filename:
string filename = "c:\\temp\\LogFile.Txt";
my command is built:
command.CommandText = "sp_UpdateLogFile '" + filename + "'";
however, sql doesnt accept the \\ directory seperators, they should only be one \.
Is there a function already available to remove these double slashes?
|
|
|
|
|
I presume your Stored Proc has a parameter, ie the filename
You should really add the file name as a parameter to the command object
ie
command.Parameter.Add("@FileName", fileName);
|
|
|
|
|
Replace[^]
filename.Replace("\\","\");
-- modified at 9:06 Friday 27th July, 2007
trash post, sorry!
All the best,
Martin
|
|
|
|
|
Or from within the stored procedure you can use something like this:
declare @test as nvarchar(40)
set @test = 'C:\\test\\rubbish\\file.asp'
select replace(@test, '\\', '\')
|
|
|
|
|
That will not do anything at all, as the string doesn't contain any double backslashes.
---
single minded; short sighted; long gone;
|
|
|
|
|
Martin# wrote: filename.Replace("\\","\");
That won't even compile. What you intended to write was:
filename.Replace("\\\\","\\");
or
filename.Replace(@"\\",@"\");
However, that will not do anything at all, as the string doesn't contain any double backslashes.
---
single minded; short sighted; long gone;
|
|
|
|
|
Sure!
All the best,
Martin
|
|
|
|
|
LOL, that wont compile
|
|
|
|
|
Mark06 wrote: sp_UpdateLogFile
Don't put "sp_" in the name of your stored procedure. "sp_" stands for "system procedure", and they are handled differently from normal stored procedures.
Mark06 wrote: sql doesnt accept the \\ directory seperators
First of all, your string doesn't contain any double backslashes. The backslash is the escape character in string literals in C#. When you put double backslashes in a string literal, the string will contain a single backslash.
Second, the database has no problems with backslashes in string literals. In MS SQL the apostrophe is the escape character, the backslash has no special meaning at all.
What has made you come to the conclusion that the database would have any problem with double backslashes, especially as your string doesn't even contain any?
---
single minded; short sighted; long gone;
|
|
|
|