我使用的是Producer-Consumer模式,我使用的BlockingCollection是生成数据并从中消耗数据的模式.我调用一个方法来生成数据,然后设置为BlockingCollection,CompleteAdding以便消费者使用来自的所有数据BlockingCollection.经过一些处理后,应用程序想要添加一些其他数据BlockingCollection,但它不能因为它被设置为CompleteAdding,如何设置CompleteAdding为false,或者如何从中消耗所有数据BlockingCollection,而不是等待ComleteAdding?
我正在尝试合并很多pdf和每个pdf我想要添加一个书签(pdf的名称),我找到了合并pdf的不同技术,但是没有一个只能添加书签,例如.itextsharp添加章节,然后是章节的书签,我不想改变pdf的.
我有一个在http://gskinner.com/RegExr/上测试过的正则表达式,它可以工作,但是当我在C#应用程序中使用它时,它失败了。
我的正则表达式:(?<!\d)\d{6}\K\d+(?=\d{4}(?!\d))
文本:4000751111115425结果:111111
我的正则表达式有什么问题?
我试图在并行中向DataTable添加一些信息,但是如果循环是长时间它会冻结或者只需要花费很多时间,那么通常用于循环,这是我的Parallel.For循环代码:
Parallel.For(1, linii.Length, index =>
{
DataRow drRow = dtResult.NewRow();
alResult = CSVParser(linii[index], txtDelimiter, txtQualifier);
for (int i = 0; i < alResult.Count; i++)
{
drRow[i] = alResult[i];
}
dtResult.Rows.Add(drRow);
}
);
Run Code Online (Sandbox Code Playgroud)
怎么了?这个Parallel.For循环比正常循环花费的时间多得多,出了什么问题?
谢谢!
我有3张桌子:
Table t1: Table t2: Table t3:
+----+----+ +----+----+ +----+----+
| i1 | i2 | | i2 | c2 | | i1 | c1 |
+----+----+ +----+----+ +----+----+
| 1 | 22 | | 11| cc | | 1 | e |
| 2 | 33 | | 22| bb | | 2 | f |
| 3 | 11 | | 33| aa | | 3 | g |
+----+----+ +----+----+ +----+----+
Run Code Online (Sandbox Code Playgroud)
并且我想使用表t1和列i1和i2从t2和c3从t3中选择colum c2,结果将是thins:
requested Tabel:
+----+----+
| c1 …Run Code Online (Sandbox Code Playgroud) 我正在尝试发送请求的原始数据并进行一些研究,并发现Page.Request.InputStream我想要的但是当我进入我的页面时它总是空的.
我是这个概念的新手,因为我来自C#中的Windows Forms Application.
这是我加载的页面:
public override void process(NameValueCollection parametersReceived)
{
string urlDestination = "";
urlDestination = parametersReceived[Includes.SUPPLIER_URL];
Stream str; String strSoapMessage = "";
Int32 strLen, strRead;
str = Request.InputStream;
strLen = Convert.ToInt32(str.Length);
byte[] strArr = new byte[strLen];
strRead = str.Read(strArr, 0, strLen);
for (int i = 0; i < strLen; i++)
{
if (strSoapMessage.Length > 0)
strSoapMessage += "&";
strSoapMessage += strArr[i].ToString();
}
saveMyLog("DATA COMMUNICATION: \n Destination: " + urlDestination + "\n Request: " + strSoapMessage);
HttpWebRequest …Run Code Online (Sandbox Code Playgroud) 我正在尝试从另一个类填充列表视图,但我发现这个错误:"跨线程操作无效:控制'listView1'从其创建的线程以外的线程访问."
在我的班级中,我声明我的列表视图是这样的:
class CheckBlankPages
{
public String[] pdfFiles
{ get; set; }
ListView _ListVireRef;
public int NrCRT = 1;
public CheckBlankPages(String[] pdfFiles = null, ListView listView = null)
{
this.pdfFiles = pdfFiles;
_ListVireRef = listView;
}
public void StartCheckingPDF()
{
foreach (string pdf in pdfFiles)
{
String[] itm = { (NrCRT++).ToString(), pdf };
ListViewItem item = new ListViewItem(itm);
_ListVireRef.Items.Add(item);
}
}
}
Run Code Online (Sandbox Code Playgroud)
在我的MainForm中我使用此代码:
DialogResult rezultat = openFileDialog1.ShowDialog();
if (rezultat == DialogResult.OK)
{
CheckBlankPages ck = new CheckBlankPages(openFileDialog1.FileNames, listView1);
Thread CheckPDFs …Run Code Online (Sandbox Code Playgroud) 我正在使用ASP.NET来读取Request.InputStream并将HttpRequest发送给发送给我的页面抛出一个QueryString参数,我正确读取了Request.InputStream并正确地进行了HttpRequest,但是在我的Request.InputStream中我发现像这样的"Porsvägen"这样的特殊字符我得到了这个错误:ystem.Net.WebException:请求被中止:请求被取消了.---> System.IO.IOException:在写入所有字节之前无法关闭流.在System.Net.ConnectStream.CloseInternal(Boolean internalCall,Boolean aborting)
我获取Request.InputStream的代码是这样的:
string requestData = (new StreamReader(Request.InputStream)).ReadToEnd();
Run Code Online (Sandbox Code Playgroud)
我制作HttpRequest并发送它的代码是这样的:
webRequest = (HttpWebRequest)WebRequest.Create(new Uri(urlDestination));
webRequest.Method = "POST";
webRequest.ContentType = "application/x-www-form-urlencoded";
webRequest.ContentLength = requestData.Length;
writer = new StreamWriter(webRequest.GetRequestStream());
writer.Write(requestData, 0, requestData.Length);//<-------Here I get the ERROR
if (writer != null)
{
writer.Close();
}
Run Code Online (Sandbox Code Playgroud)
你能否告诉我我的代码有什么问题,因为它有效,但对于特殊字符,它会崩溃.
我在VBScript中创建了一个类,并在asp经典中用它来实现一个对象:这是我的类:
<%
Class RBAC
Public dateTimeValue
Public userIdValue
Public fileIdValue
Public actionValue
Public Property Get DateTime()
'Gets the propery value
DateTime = dateTimeValue
End Property
Public Property Set DateTime(value)
'Sets the property value
dateTimeValue = value
End Property
Public Property Get UserId()
'Gets the propery value
UserId = userIdValue
End Property
Public Property Set UserId(value)
'Sets the property value
userIdValue = value
End Property
Public Property Get FileId()
'Gets the propery value
FileId = fileIdValue
End Property
Public Property Set …Run Code Online (Sandbox Code Playgroud) 我正在尝试从只有特定行的数据集填充组合框,这是我的代码:
comboBox2.DataSource = glObalDataSet.Tables["JOBURI"].Select(
"CONT = '" + comboBox1.SelectedValue.ToString() + "'");
Run Code Online (Sandbox Code Playgroud)
数据集运行正常,它是填充的,有人可以告诉我我在哪里做错了吗?
我有一个应用程序检查一些7zip arhive,如果它们没有损坏,我想在列表框中编写每个动作,但我的问题是当我向它添加一个项目时,列表框不显示每一行,它完成后更新,即使我使用属性,也将所有项目放在我的操作结束.StartUpdate()和EndUpdate()
这是我的代码的一部分:
foreach (string director in foldere)
{
if (director.ToLower().Contains("cluj") || director.ToLower().Contains("craiova") || director.ToLower().Contains("timisoara"))
{
String[] zipFile = Directory.GetFiles(director, "*.7z");
foreach (string zip7 in zipFile)
{
//check arhive
SevenZipExtractor zipfile = new SevenZipExtractor(zip7);
if (zipfile.Check())
{
String[] fisFaraArhiva = Directory.GetFiles(director, "*.*");
foreach (string fisere in fisFaraArhiva)
{
if (fisere != zip7)
{
File.Delete(fisere);
}
}
listBox1.Items.Insert(0, "A fost sters fisierele din directorul " + director);
string[] fisComanda = Directory.GetFiles(utilizator, "*" + id + "*");
foreach (string cmd in fisComanda) …Run Code Online (Sandbox Code Playgroud) 我有以下代码:
public partial class Root : ICustomInterface
{
public virtual void Display()
{
Console.WriteLine("Root");
Console.ReadLine();
}
}
public class Child : Root
{
public override void Display()
{
Console.WriteLine("Child");
Console.ReadLine();
}
}
class Program
{
static void Main(string[] args)
{
Root temp;
temp = new Root();
temp.Display();
}
}
Output: "Root"
Desired output: "Child"
Run Code Online (Sandbox Code Playgroud)
当我实例化一个Root对象并调用该Display()方法时,我想显示重写方法,Child这是可能的.
我需要这个,因为我必须创建一个插件,该插件是基本代码的扩展Display(),并使Root类的方法无效并仅实现插件的方法Child
我正在尝试设置pdf的背景并设法用图像设置我的pdf有一个大表,所以页面是自动添加的,而不是使用Document.NewPage()方法,所以图像背景只在第一页上设置.这是添加背景的代码:
Image backImg = Image.GetInstance(@"D:\websites\DIS\bugs\130208\A4.png");
backImg.SetAbsolutePosition(0, 0);
backImg.Alignment = Image.UNDERLYING;
var doc = new Document(pageSize);
PdfWriter pdfWriter = PdfWriter.GetInstance(doc, new FileStream(filePath, FileMode.Create));
doc.Open();
doc.Add(backImg);
...
creating a big table
Run Code Online (Sandbox Code Playgroud)
而不是使用该doc.NewPage()方法.在关闭文档之前,我是否必须循环抛出每个页面并在结尾处添加背景图像,但是如何将其放在后台而不是其他元素之上?
c# ×10
winforms ×3
asp.net ×2
.net ×1
.net-4.0 ×1
asp-classic ×1
class ×1
combobox ×1
data-binding ×1
dataset ×1
datatable ×1
inheritance ×1
interface ×1
itext ×1
itextsharp ×1
listbox ×1
merge ×1
overriding ×1
pdf ×1
regex ×1
sql ×1
vbscript ×1