|
Please read this post[^] then edit your question to provide more detail.
[EDIT - Note that I have suggested that you edit this post. Do not repost the same question yet again - see your earlier post[^]
This is twice you have been advised to post more detail. Help us to help you
|
|
|
|
|
Hi ,
i am creating pdf using iTextsharp dll , now i want some free/open source dll which will be a control to view the pdf in winform . I dont want any com component or webbrowser control to view . i need no dependencies too. I am finding it very challenging, can any help me with my RnD ?
|
|
|
|
|
Anthony Fernando wrote: i want some free/open source dll Then you need to post your requirements to Google.
|
|
|
|
|
|
Well, if you don't want any dependencies, you're going to have to rely on writing your own. There is a PDF specification but it's not a trivial thing to read, or implement. This article[^] shows you how many libraries you are going to have to replicate parts of.
|
|
|
|
|
Hi Pete ,
I have seen that article.
what are the other ways to view pdf document ?
PDFviewer or Adobe reader can be used from component but i dont want to use that.
Is there any other dll which will allow me to display pdf in winform ?
|
|
|
|
|
|
Hi Garth
Do you SPire.PDFViewer dll will allow me to display pdf while which will contain on 10 Pages?
|
|
|
|
|
from their web page "Free version is limited to 10 pages of PDF when viewing and printing PDF files."
|
|
|
|
|
That's a limited version of a commercial control which regularly appears in spam messages in these forums and QA. I'm surprised your message made it through the spam filter.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
bvgger - didn't know that ....
|
|
|
|
|
If you want "no dependencies", why are you creating PDF's?
Instead, create a plain text file; or an .RTF; or convert the PDF to XPS; or anything else that has "no dependencies" (outside of that provided by Windows and .NET).
If it's simply for "viewing in WinForms", then the format of the input should not be limited to only PDF's.
And why view in WinForms at all? Just "process start" whatever PDF viewer a user has installed (and probably prefers).
|
|
|
|
|
i am trying to understand async and await concept. so i am make sample program when i run this program take 8 seconds to execute if i execute without async and await it also take 8 second to execute. so what is wrong in this program.
protected async void btnSubmit_Click(object sender, EventArgs e)
{
Response.Write(DateTime.Now.ToString("dd-MM-yyyy:hh:mm:ss") + " <br/>");
//dowork();
await Task.Run(() => dowork());
// await Task.Run(() => DoAnotherWork());
DoAnotherWork();
Response.Write(DateTime.Now.ToString("dd-MM-yyyy:hh:mm:ss") + " <br/>");
// btnSubmit.Text="Done it";
}
void dowork()
{
Thread.Sleep(5000);
}
void DoAnotherWork()
{
Thread.Sleep(3000);
}
|
|
|
|
|
How long would you expect it to complete in? You have 8 seconds worth of operation in there. I assume that you think that dowork will happen at the same time as DoAnotherWork. That's not the way that await operates. It's not, despite what you may think, something that pushes an operation off to another thread and continues processing in that thread - instead, it suspends the operation of the current method until the awaited operation completes. So, you end up with an 8 second delay.
|
|
|
|
|
yes, i was thinking it should completed in 5 seconds. So please clarify to me await and async concept.
thanks your help
|
|
|
|
|
I just have clarified it for you. The await keyword suspends the method until the task it's waiting on completes, then it moves onto the next operation in the chain. I'm not sure how else I can put this for you.
|
|
|
|
|
thanks Peter for your help
|
|
|
|
|
Anil0007 wrote: i was thinking it should completed in 5 seconds Well, if you modify your code something like this, it "might" run in 5 seconds..
Task t0 = Task.Factory.StartNew(() => dowork());
Task t1 = Task.Factory.StartNew(() => DoAnotherWork());
await Task.WhenAll(t0, t1);
You have just been Sharapova'd.
|
|
|
|
|
Using await doesn't mean your code acts asynchronously. It still behaves as if the code is running synchronously (which is why it takes 8 seconds) but the difference is that when using await the underlying framework means the thread is available to use for other tasks if needed. If you didn't use await and instead just waited for the task to finish then your code would act no differently, but the thread that is waiting for the result can't be used for something else if needed. If you remove the "await" from the dowork then the method will take 3 seconds as dowork will be started on its own task and that will execute asynchronously and then DoAnotherWork will be called which will block for 3s synchronously.
dowork();
Task.Run(() => dowork());
await Task.Run(() => dowork());
|
|
|
|
|
It's not usually recommended to use Task.Run to convert a synchronous method to an async Task , especially if you're going to immediately await that Task :
Should I expose asynchronous wrappers for synchronous methods? | Stephen Toub[^]
Instead, it's better to push the asynchronous operation down, and make the method your calling return a Task .
Also, when you're using async , you should try to avoid Thread.Sleep ; use await Task.Delay(...) instead:
Visual C#: Thread.Sleep vs. Task.Delay[^]
And as Agent__007 said, if you want both methods to run in parallel, you need to use Task.WhenAll to wait for them.
protected async void btnSubmit_Click(object sender, EventArgs e)
{
Response.Write(DateTime.Now.ToString("dd-MM-yyyy:hh:mm:ss") + " <br/>");
Task first = dowork();
Task second = DoAnotherWork();
await Task.WhenAll(first, second);
Response.Write(DateTime.Now.ToString("dd-MM-yyyy:hh:mm:ss") + " <br/>");
}
async Task dowork()
{
await Task.Delay(5000);
}
async Task DoAnotherWork()
{
await Task.Delay(3000);
}
Since you're using ASP.NET WebForms, you should consider using the RegisterAsyncTask method[^] to run your async code, and avoid using async void where possible:
Using Asynchronous Methods in ASP.NET 4.5[^]
The Magic of using Asynchronous Methods in ASP.NET 4.5 plus an important gotcha[^]
Some useful resources:
Async and Await | Stephen Cleary[^]
Async/Await - Best Practices in Asynchronous Programming | Stephen Cleary[^]
Parallel Programming with .NET | MSDN Blogs[^]
await (C# Reference)[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hello!
sub-category table
category table
i am working on Point of sale application and i want to get sub-category data when i click on category tile view I tried alot but i couldn't find any good solution.
PLEASE guide me SO I CAN MOVE FORWARD .
|
|
|
|
|
This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind.
So explain exactly what you have tried, where you are stuck, and what help you need.
Tell us what environment you are working in, what controls you are using, how you load data into them.
Without that, it's like trying to fix your car without even knowing where it is, much less what make or model it is, or what parts we need!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Why I can not save the error information in the table: TABERRORINFO. Suppose I have two: TABCUSTOMER and TABERRORINFO.
private void cmdSave_Click(object sender, EventArgs e)
{
strSQL = "INSERT INTO TABCUSTOMER(IDCUSTOMER, FULLNAME, ADDRESS, IMAGE) " +
"VALUES (@IDCUSTOME, @FULLNAME, @ADDRESS, @ImageData);";
SqlCommand cmd = new SqlCommand(strSQL, ClsConnection.objConnect);
try
{
cmd.Parameters.AddWithValue("@IDCUSTOMER", txtIDCustomer.Text);
cmd.Parameters.AddWithValue("@FULLNAME", txtFullName.Text);
cmd.Parameters.AddWithValue("@ADDRESS", txtAddress.Text);
//byte[] ImageData = ReadFile(sPath);
cmd.Parameters.Add(new SqlParameter("@ImageData", (object)ImageData));
if (ClsConnection.objConnect.State != System.Data.ConnectionState.Open)
{
ClsConnection.objConnect.Open();
}
cmd.CommandType = CommandType.Text;
cmd.ExecuteNonQuery();
ClsConnection.objConnect.Close();
}
catch (SqlException ex)
{
ClsConnection.objConnect.Close();
string sConError = "Save Messager Customer 1: " + ex.Message;
SaveMessageErrSQL(sConError, strSQL);
}
}
private void SaveMessageErrSQL(string MessErr, string SqlErr)
{
string sSQL = "UPDATE TABERRORINFO SET ";
sSQL = sSQL + " ERRDATE = @NgayErr";
sSQL = sSQL + ", ERRMESSAGE = @MesaErr";
sSQL = sSQL + ", ERRSQL = @SQLErr";
sSQL = sSQL + " WHERE USERNAME = N'" + sUSERNAME + "';";
Debug.Print(sSQL);
SqlCommand cmd = new SqlCommand(sSQL, objConnect);
try
{
cmd.Parameters.AddWithValue("@NgayErr", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
cmd.Parameters.AddWithValue("@MesaErr", MessErr);
cmd.Parameters.AddWithValue("@SQLErr", SqlErr);
cmd.CommandType = CommandType.Text;
cmd.ExecuteNonQuery();
objConnect.Close();
DevExpress.XtraEditors.XtraMessageBox.Show("Saved" + MessErr);
}
catch (SqlException ex)
{<br />
objConnect.Close();
MessageBox.Show("No Save Message Errer into SQL: " + ex.Message);
}
}
|
|
|
|
|
You didn't post the error message so there's no way of knowing what err you actually encounter.
However, there are some issues with the code:
|
|
|
|
|
The follow I thought, you do not care about error codes because I intentionally create/caused the error by adding IMAGE and cmd.Parameters.Add(new SqlParameter("@ImageData", (object)ImageData)) to catch (SqlException ex) call SaveMessageErrSQL(...)
|
|
|
|